[llvm-commits] [llvm] r136329 - /llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
Bill Wendling
isanbard at gmail.com
Wed Jul 27 19:40:14 PDT 2011
Author: void
Date: Wed Jul 27 21:40:13 2011
New Revision: 136329
URL: http://llvm.org/viewvc/llvm-project?rev=136329&view=rev
Log:
Automatically merge the landingpad clauses when we come across a callee's
landingpad.
Modified:
llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=136329&r1=136328&r2=136329&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Wed Jul 27 21:40:13 2011
@@ -250,7 +250,7 @@
PHINode *InnerSelectorPHI;
SmallVector<Value*, 8> UnwindDestPHIValues;
- SmallVector<LandingPadInst*, 16> CalleeLPads;
+ PHINode *InnerEHValuesPHI;
LandingPadInst *CallerLPad;
BasicBlock *SplitLPad;
@@ -258,7 +258,7 @@
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 @@
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 @@
/// 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 @@
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 @@
/// 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 @@
}
if (ResumeInst *RI = dyn_cast<ResumeInst>(BB->getTerminator())) {
- Invoke.mergeLandingPadClauses(RI);
Invoke.forwardResume(RI);
}
}
More information about the llvm-commits
mailing list