Fix inlining to not produce duplicate landingpad clauses
authorMark Seaborn <mseaborn@chromium.org>
Sun, 8 Dec 2013 00:50:58 +0000 (00:50 +0000)
committerMark Seaborn <mseaborn@chromium.org>
Sun, 8 Dec 2013 00:50:58 +0000 (00:50 +0000)
commit615f9b7162ac6444c9e45042477634b73ba8850a
tree3fc110c71e119f6478b0d4dd5d253878a05660ba
parent1de81334024df0f59ef2e5f1af2701ca7c04068c
Fix inlining to not produce duplicate landingpad clauses

Before this change, inlining one "invoke" into an outer "invoke" call
site can lead to the outer landingpad's catch/filter clauses being
copied multiple times into the resulting landingpad.  This happens:

 * when the inlined function contains multiple "resume" instructions,
   because forwardResume() copies the clauses but is called multiple
   times;

 * when the inlined function contains a "resume" and a "call", because
   HandleCallsInBlockInlinedThroughInvoke() copies the clauses but is
   redundant with forwardResume().

Fix this by deduplicating the code.

This problem doesn't lead to any incorrect execution; it's only
untidy.

This change will make fixing PR17872 a little easier.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196710 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Utils/InlineFunction.cpp
test/Transforms/Inline/inline_invoke.ll
test/Transforms/Inline/invoke-combine-clauses.ll [new file with mode: 0644]