From 3cc48a062821557a2ccaa8df26dd3a98d64c44b9 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171846 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Utils/DemoteRegToStack.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/Transforms/Utils/DemoteRegToStack.cpp') diff --git a/lib/Transforms/Utils/DemoteRegToStack.cpp b/lib/Transforms/Utils/DemoteRegToStack.cpp index ee59e94655..d5c41f5459 100644 --- a/lib/Transforms/Utils/DemoteRegToStack.cpp +++ b/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.2.3-18-g5258