Make sure we don't emit instructions before a landingpad instruction.

PR14782


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171846 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bill Wendling
2013-01-08 10:51:32 +00:00
parent 0b740236b7
commit 3cc48a0628
3 changed files with 95 additions and 1 deletions

View File

@ -124,7 +124,12 @@ AllocaInst *llvm::DemotePHIToStack(PHINode *P, Instruction *AllocaPoint) {
}
// Insert a load in place of the PHI and replace all uses.
Value *V = new LoadInst(Slot, P->getName()+".reload", P);
BasicBlock::iterator InsertPt = P;
for (; isa<PHINode>(InsertPt) || isa<LandingPadInst>(InsertPt); ++InsertPt)
/* empty */; // Don't insert before PHI nodes or landingpad instrs.
Value *V = new LoadInst(Slot, P->getName()+".reload", InsertPt);
P->replaceAllUsesWith(V);
// Delete PHI.