diff --git a/llvm/lib/CodeGen/WinEHPrepare.cpp b/llvm/lib/CodeGen/WinEHPrepare.cpp index 1d5206c6cadf..6f712a914f98 100644 --- a/llvm/lib/CodeGen/WinEHPrepare.cpp +++ b/llvm/lib/CodeGen/WinEHPrepare.cpp @@ -320,6 +320,7 @@ bool WinEHPrepare::prepareCPPEHHandlers( // that pull the EHObjPtr from the frame alloc structure for (AllocaInst *EHObjPtr : HandlerEHObjPtrs) { Value *EHData = EHDataMap[EHObjPtr->getParent()->getParent()]; + Builder.SetInsertPoint(EHObjPtr); Value *ElementPtr = Builder.CreateConstInBoundsGEP2_32(EHData, 0, 1); EHObjPtr->replaceAllUsesWith(ElementPtr); EHObjPtr->removeFromParent();