summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/InlineFunction.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2011-07-28 02:40:13 +0000
committerBill Wendling <isanbard@gmail.com>2011-07-28 02:40:13 +0000
commite8ce880f1a66dffcad7955868be5193e782c09ca (patch)
treecbb947b9f1fdea49204aa3f997689de438850e88 /lib/Transforms/Utils/InlineFunction.cpp
parent4ebc5916e9b3a43af8aff8e1b8744b1644457a4b (diff)
downloadllvm-e8ce880f1a66dffcad7955868be5193e782c09ca.tar.gz
llvm-e8ce880f1a66dffcad7955868be5193e782c09ca.tar.bz2
llvm-e8ce880f1a66dffcad7955868be5193e782c09ca.tar.xz
Automatically merge the landingpad clauses when we come across a callee's
landingpad. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136329 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r--lib/Transforms/Utils/InlineFunction.cpp40
1 files changed, 12 insertions, 28 deletions
diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp
index 135455e081..8eda3e0b0d 100644
--- a/lib/Transforms/Utils/InlineFunction.cpp
+++ b/lib/Transforms/Utils/InlineFunction.cpp
@@ -250,7 +250,7 @@ namespace {
PHINode *InnerSelectorPHI;
SmallVector<Value*, 8> UnwindDestPHIValues;
- SmallVector<LandingPadInst*, 16> CalleeLPads;
+ PHINode *InnerEHValuesPHI;
LandingPadInst *CallerLPad;
BasicBlock *SplitLPad;
@@ -258,7 +258,7 @@ namespace {
InvokeInliningInfo(InvokeInst *II)
: OuterUnwindDest(II->getUnwindDest()), OuterSelector(0),
InnerUnwindDest(0), InnerExceptionPHI(0), InnerSelectorPHI(0),
- CallerLPad(0), SplitLPad(0) {
+ InnerEHValuesPHI(0), CallerLPad(0), SplitLPad(0) {
// If there are PHI nodes in the unwind destination block, we
// need to keep track of which values came into them from the
// invoke before removing the edge from this block.
@@ -289,10 +289,6 @@ namespace {
BasicBlock *getInnerUnwindDest();
- void addCalleeLandingPad(LandingPadInst *LPI) {
- CalleeLPads.push_back(LPI);
- }
-
LandingPadInst *getLandingPadInst() const { return CallerLPad; }
BasicBlock *getSplitLandingPad() {
if (SplitLPad) return SplitLPad;
@@ -311,11 +307,6 @@ namespace {
/// to there.
void forwardResume(ResumeInst *RI);
- /// mergeLandingPadClauses - Visit all of the landing pad instructions which
- /// supply the value for the ResumeInst, and merge the clauses from the new
- /// destination (the caller's landing pad).
- void mergeLandingPadClauses(ResumeInst *RI);
-
/// addIncomingPHIValuesFor - Add incoming-PHI values to the unwind
/// destination block for the given basic block, using the values for the
/// original invoke's source block.
@@ -436,16 +427,6 @@ bool InvokeInliningInfo::forwardEHResume(CallInst *call, BasicBlock *src) {
return true;
}
-/// mergeLandingPadClauses - Visit all of the landing pad instructions merge the
-/// clauses from the new destination (the caller's landing pad).
-void InvokeInliningInfo::mergeLandingPadClauses(ResumeInst *RI) {
- for (SmallVectorImpl<LandingPadInst*>::iterator
- I = CalleeLPads.begin(), E = CalleeLPads.end(); I != E; ++I)
- for (unsigned i = 0, e = CallerLPad->getNumClauses(); i != e; ++i)
- (*I)->addClause(CallerLPad->getClauseType(i),
- CallerLPad->getClauseValue(i));
-}
-
/// forwardResume - Forward the 'resume' instruction to the caller's landing pad
/// block. When the landing pad block has only one predecessor, this is a simple
/// branch. When there is more than one predecessor, we need to split the
@@ -498,15 +479,19 @@ static bool isCleanupOnlySelector(EHSelectorInst *selector) {
/// Returns true to indicate that the next block should be skipped.
static bool HandleCallsInBlockInlinedThroughInvoke(BasicBlock *BB,
InvokeInliningInfo &Invoke) {
+ LandingPadInst *LPI = Invoke.getLandingPadInst();
+
for (BasicBlock::iterator BBI = BB->begin(), E = BB->end(); BBI != E; ) {
Instruction *I = BBI++;
- // Collect the callee's landingpad instructions.
- if (LandingPadInst *LPI = dyn_cast<LandingPadInst>(I)) {
- Invoke.addCalleeLandingPad(LPI);
- continue;
- }
-
+ if (LPI) // FIXME: This won't be NULL in the new EH.
+ if (LandingPadInst *L = dyn_cast<LandingPadInst>(I)) {
+ unsigned NumClauses = LPI->getNumClauses();
+ L->reserveClauses(NumClauses);
+ for (unsigned i = 0; i != NumClauses; ++i)
+ L->addClause(LPI->getClauseType(i), LPI->getClauseValue(i));
+ }
+
// We only need to check for function calls: inlined invoke
// instructions require no special handling.
CallInst *CI = dyn_cast<CallInst>(I);
@@ -642,7 +627,6 @@ static void HandleInlinedInvoke(InvokeInst *II, BasicBlock *FirstNewBlock,
}
if (ResumeInst *RI = dyn_cast<ResumeInst>(BB->getTerminator())) {
- Invoke.mergeLandingPadClauses(RI);
Invoke.forwardResume(RI);
}
}