diff options
author | Bill Wendling <isanbard@gmail.com> | 2013-10-21 04:09:17 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2013-10-21 04:09:17 +0000 |
commit | 3e033f29239e48c190f29cdf3a02cdfbaf2fe72b (patch) | |
tree | 6022b73253983a58bc69e4a9f9b8c764a0b1cfee /lib | |
parent | 365f4fa6cb9ef2e87483219784349008e6d20ae9 (diff) | |
download | llvm-3e033f29239e48c190f29cdf3a02cdfbaf2fe72b.tar.gz llvm-3e033f29239e48c190f29cdf3a02cdfbaf2fe72b.tar.bz2 llvm-3e033f29239e48c190f29cdf3a02cdfbaf2fe72b.tar.xz |
Don't eliminate a partially redundant load if it's in a landing pad.
A landing pad can be jumped to only by the unwind edge of an invoke
instruction. If we eliminate a partially redundant load in a landing pad, it
will create a basic block that violates this constraint. It then leads to other
problems down the line if it tries to merge that basic block with the landing
pad. Avoid this by not eliminating the load in a landing pad.
PR17621
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193064 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Scalar/JumpThreading.cpp | 7 | ||||
-rw-r--r-- | lib/Transforms/Utils/Local.cpp | 15 |
2 files changed, 7 insertions, 15 deletions
diff --git a/lib/Transforms/Scalar/JumpThreading.cpp b/lib/Transforms/Scalar/JumpThreading.cpp index 0b8906d43f..b3ec2fc84c 100644 --- a/lib/Transforms/Scalar/JumpThreading.cpp +++ b/lib/Transforms/Scalar/JumpThreading.cpp @@ -827,7 +827,6 @@ bool JumpThreading::ProcessBlock(BasicBlock *BB) { return false; } - /// SimplifyPartiallyRedundantLoad - If LI is an obviously partially redundant /// load instruction, eliminate it by replacing it with a PHI node. This is an /// important optimization that encourages jump threading, and needs to be run @@ -842,6 +841,12 @@ bool JumpThreading::SimplifyPartiallyRedundantLoad(LoadInst *LI) { if (LoadBB->getSinglePredecessor()) return false; + // If the load is defined in a landing pad, it can't be partially redundant, + // because the edges between the invoke and the landing pad cannot have other + // instructions between them. + if (LoadBB->isLandingPad()) + return false; + Value *LoadedPtr = LI->getOperand(0); // If the loaded operand is defined in the LoadBB, it can't be available. diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp index 78217c8efa..82b8da3a10 100644 --- a/lib/Transforms/Utils/Local.cpp +++ b/lib/Transforms/Utils/Local.cpp @@ -503,19 +503,7 @@ void llvm::MergeBasicBlockIntoOnlyPred(BasicBlock *DestBB, Pass *P) { // Splice all the instructions from PredBB to DestBB. PredBB->getTerminator()->eraseFromParent(); - - // First splice over the PHI nodes. - BasicBlock::iterator PI = PredBB->begin(); - while (isa<PHINode>(PI)) - ++PI; - - if (PI != PredBB->begin()) - DestBB->getInstList().splice(DestBB->begin(), PredBB->getInstList(), - PredBB->begin(), PI); - - // Now splice over the rest of the instructions. - DestBB->getInstList().splice(DestBB->getFirstInsertionPt(), - PredBB->getInstList(), PI, PredBB->end()); + DestBB->getInstList().splice(DestBB->begin(), PredBB->getInstList()); if (P) { DominatorTree *DT = P->getAnalysisIfAvailable<DominatorTree>(); @@ -525,7 +513,6 @@ void llvm::MergeBasicBlockIntoOnlyPred(BasicBlock *DestBB, Pass *P) { DT->eraseNode(PredBB); } } - // Nuke BB. PredBB->eraseFromParent(); } |