From 76c6521ba17ed6134d91ca2728250b67b720650b Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Tue, 8 Jan 2013 10:51:32 +0000 Subject: Make sure we don't emit instructions before a landingpad instruction. PR14782 llvm-svn: 171846 --- llvm/lib/Transforms/Utils/DemoteRegToStack.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Transforms/Utils/DemoteRegToStack.cpp') diff --git a/llvm/lib/Transforms/Utils/DemoteRegToStack.cpp b/llvm/lib/Transforms/Utils/DemoteRegToStack.cpp index ee59e94..d5c41f5 100644 --- a/llvm/lib/Transforms/Utils/DemoteRegToStack.cpp +++ b/llvm/lib/Transforms/Utils/DemoteRegToStack.cpp @@ -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(InsertPt) || isa(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. -- cgit v1.1