[WinEH] Insert the EH code load before the block terminator

The previous code put the load after the terminator, leading to invalid
IR and downstream crashes. This caused http://crbug.com/506446.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241509 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Kleckner
2015-07-06 21:13:43 +00:00
parent 3ecdd44e5d
commit e23370402c
2 changed files with 67 additions and 1 deletions

View File

@@ -833,7 +833,7 @@ bool WinEHPrepare::prepareExceptionHandlers(
LoadInst *LI;
if (auto *Phi = dyn_cast<PHINode>(I))
LI = new LoadInst(SEHExceptionCodeSlot, "sehcode", false,
Phi->getIncomingBlock(*U));
Phi->getIncomingBlock(*U)->getTerminator());
else
LI = new LoadInst(SEHExceptionCodeSlot, "sehcode", false, I);
U->set(LI);