<div dir="ltr">While you're here touching this code, have you seen <a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/2050/steps/check-llvm%20msan/logs/stdio">http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/2050/steps/check-llvm%20msan/logs/stdio</a>?</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 3, 2015 at 3:20 PM, Reid Kleckner <span dir="ltr"><<a href="mailto:reid@kleckner.net" target="_blank">reid@kleckner.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rnk<br>
Date: Tue Mar 3 17:20:30 2015<br>
New Revision: 231164<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=231164&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=231164&view=rev</a><br>
Log:<br>
WinEH: Remove vestigial EH object<br>
<br>
Ultimately, we'll need to leave something behind to indicate which<br>
alloca will hold the exception, but we can figure that out when it comes<br>
time to emit the __CxxFrameHandler3 catch handler table.<br>
<br>
Modified:<br>
llvm/trunk/lib/CodeGen/WinEHPrepare.cpp<br>
llvm/trunk/test/CodeGen/WinEH/cppeh-catch-all.ll<br>
llvm/trunk/test/CodeGen/WinEH/cppeh-catch-scalar.ll<br>
llvm/trunk/test/CodeGen/WinEH/cppeh-frame-vars.ll<br>
llvm/trunk/test/CodeGen/WinEH/cppeh-inalloca.ll<br>
llvm/trunk/test/CodeGen/WinEH/cppeh-nonalloca-frame-values.ll<br>
<br>
Modified: llvm/trunk/lib/CodeGen/WinEHPrepare.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/WinEHPrepare.cpp?rev=231164&r1=231163&r2=231164&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/WinEHPrepare.cpp?rev=231164&r1=231163&r2=231164&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/WinEHPrepare.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/WinEHPrepare.cpp Tue Mar 3 17:20:30 2015<br>
@@ -73,8 +73,7 @@ private:<br>
SmallVectorImpl<LandingPadInst *> &LPads);<br>
bool outlineHandler(HandlerType CatchOrCleanup, Function *SrcFn,<br>
Constant *SelectorType, LandingPadInst *LPad,<br>
- CallInst *&EHAlloc, AllocaInst *&EHObjPtr,<br>
- FrameVarInfoMap &VarInfo);<br>
+ CallInst *&EHAlloc, FrameVarInfoMap &VarInfo);<br>
};<br>
<br>
class WinEHFrameVariableMaterializer : public ValueMaterializer {<br>
@@ -132,9 +131,9 @@ protected:<br>
class WinEHCatchDirector : public WinEHCloningDirectorBase {<br>
public:<br>
WinEHCatchDirector(LandingPadInst *LPI, Function *CatchFn, Value *Selector,<br>
- Value *EHObj, FrameVarInfoMap &VarInfo)<br>
+ FrameVarInfoMap &VarInfo)<br>
: WinEHCloningDirectorBase(LPI, CatchFn, VarInfo),<br>
- CurrentSelector(Selector->stripPointerCasts()), EHObj(EHObj) {}<br>
+ CurrentSelector(Selector->stripPointerCasts()) {}<br>
<br>
CloningAction handleBeginCatch(ValueToValueMapTy &VMap,<br>
const Instruction *Inst,<br>
@@ -149,7 +148,6 @@ public:<br>
<br>
private:<br>
Value *CurrentSelector;<br>
- Value *EHObj;<br>
};<br>
<br>
class WinEHCleanupDirector : public WinEHCloningDirectorBase {<br>
@@ -239,7 +237,6 @@ bool WinEHPrepare::prepareCPPEHHandlers(<br>
// handlers are outlined.<br>
FrameVarInfoMap FrameVarInfo;<br>
SmallVector<CallInst *, 4> HandlerAllocs;<br>
- SmallVector<AllocaInst *, 4> HandlerEHObjPtrs;<br>
<br>
bool HandlersOutlined = false;<br>
<br>
@@ -267,17 +264,14 @@ bool WinEHPrepare::prepareCPPEHHandlers(<br>
// Create a new instance of the handler data structure in the<br>
// HandlerData vector.<br>
CallInst *EHAlloc = nullptr;<br>
- AllocaInst *EHObjPtr = nullptr;<br>
bool Outlined = outlineHandler(Catch, &F, LPad->getClause(Idx), LPad,<br>
- EHAlloc, EHObjPtr, FrameVarInfo);<br>
+ EHAlloc, FrameVarInfo);<br>
if (Outlined) {<br>
HandlersOutlined = true;<br>
// These values must be resolved after all handlers have been<br>
// outlined.<br>
if (EHAlloc)<br>
HandlerAllocs.push_back(EHAlloc);<br>
- if (EHObjPtr)<br>
- HandlerEHObjPtrs.push_back(EHObjPtr);<br>
}<br>
} // End if (isCatch)<br>
} // End for each clause<br>
@@ -290,9 +284,8 @@ bool WinEHPrepare::prepareCPPEHHandlers(<br>
// when landing pad block analysis is added.<br>
if (LPad->isCleanup()) {<br>
CallInst *EHAlloc = nullptr;<br>
- AllocaInst *IgnoreEHObjPtr = nullptr;<br>
- bool Outlined = outlineHandler(Cleanup, &F, nullptr, LPad, EHAlloc,<br>
- IgnoreEHObjPtr, FrameVarInfo);<br>
+ bool Outlined =<br>
+ outlineHandler(Cleanup, &F, nullptr, LPad, EHAlloc, FrameVarInfo);<br>
if (Outlined) {<br>
HandlersOutlined = true;<br>
// This value must be resolved after all handlers have been outlined.<br>
@@ -399,18 +392,6 @@ bool WinEHPrepare::prepareCPPEHHandlers(<br>
EHDataMap[EHAlloc->getParent()->getParent()] = EHData;<br>
}<br>
<br>
- // Next, replace the place-holder EHObjPtr allocas with GEP instructions<br>
- // that pull the EHObjPtr from the frame alloc structure<br>
- for (AllocaInst *EHObjPtr : HandlerEHObjPtrs) {<br>
- Value *EHData = EHDataMap[EHObjPtr->getParent()->getParent()];<br>
- Builder.SetInsertPoint(EHObjPtr);<br>
- Value *ElementPtr = Builder.CreateConstInBoundsGEP2_32(EHData, 0, 1);<br>
- EHObjPtr->replaceAllUsesWith(ElementPtr);<br>
- EHObjPtr->removeFromParent();<br>
- ElementPtr->takeName(EHObjPtr);<br>
- delete EHObjPtr;<br>
- }<br>
-<br>
// Finally, replace all of the temporary allocas for frame variables used in<br>
// the outlined handlers and the original frame allocas with GEP instructions<br>
// that get the equivalent pointer from the frame allocation struct.<br>
@@ -490,7 +471,7 @@ bool WinEHPrepare::prepareCPPEHHandlers(<br>
<br>
bool WinEHPrepare::outlineHandler(HandlerType CatchOrCleanup, Function *SrcFn,<br>
Constant *SelectorType, LandingPadInst *LPad,<br>
- CallInst *&EHAlloc, AllocaInst *&EHObjPtr,<br>
+ CallInst *&EHAlloc,<br>
FrameVarInfoMap &VarInfo) {<br>
Module *M = SrcFn->getParent();<br>
LLVMContext &Context = M->getContext();<br>
@@ -539,20 +520,8 @@ bool WinEHPrepare::outlineHandler(Handle<br>
std::unique_ptr<WinEHCloningDirectorBase> Director;<br>
<br>
if (CatchOrCleanup == Catch) {<br>
- // This alloca is only temporary. We'll be replacing it once we know all<br>
- // the frame variables that need to go in the frame allocation structure.<br>
- EHObjPtr = Builder.CreateAlloca(Int8PtrType, 0, "eh.obj.ptr");<br>
-<br>
- // This will give us a raw pointer to the exception object, which<br>
- // corresponds to the formal parameter of the catch statement. If the<br>
- // handler uses this object, we will generate code during the outlining<br>
- // process to cast the pointer to the appropriate type and deference it<br>
- // as necessary. The un-outlined landing pad code represents the<br>
- // exception object as the result of the llvm.eh.begincatch call.<br>
- Value *EHObj = Builder.CreateLoad(EHObjPtr, false, "eh.obj");<br>
-<br>
Director.reset(<br>
- new WinEHCatchDirector(LPad, Handler, SelectorType, EHObj, VarInfo));<br>
+ new WinEHCatchDirector(LPad, Handler, SelectorType, VarInfo));<br>
} else {<br>
Director.reset(new WinEHCleanupDirector(LPad, Handler, VarInfo));<br>
}<br>
@@ -668,10 +637,11 @@ CloningDirector::CloningAction WinEHCatc<br>
// The argument to the call is some form of the first element of the<br>
// landingpad aggregate value, but that doesn't matter. It isn't used<br>
// here.<br>
- // The return value of this instruction, however, is used to access the<br>
- // EH object pointer. We have generated an instruction to get that value<br>
- // from the EH alloc block, so we can just map to that here.<br>
- VMap[Inst] = EHObj;<br>
+ // The second argument is an outparameter where the exception object will be<br>
+ // stored. Typically the exception object is a scalar, but it can be an<br>
+ // aggregate when catching by value.<br>
+ // FIXME: Leave something behind to indicate where the exception object lives<br>
+ // for this handler. Should it be part of llvm.eh.actions?<br>
return CloningDirector::SkipInstruction;<br>
}<br>
<br>
<br>
Modified: llvm/trunk/test/CodeGen/WinEH/cppeh-catch-all.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WinEH/cppeh-catch-all.ll?rev=231164&r1=231163&r2=231164&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WinEH/cppeh-catch-all.ll?rev=231164&r1=231163&r2=231164&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/CodeGen/WinEH/cppeh-catch-all.ll (original)<br>
+++ llvm/trunk/test/CodeGen/WinEH/cppeh-catch-all.ll Tue Mar 3 17:20:30 2015<br>
@@ -56,8 +56,6 @@ try.cont:<br>
; CHECK: entry:<br>
; CHECK: %eh.alloc = call i8* @llvm.framerecover(i8* bitcast (void ()* @_Z4testv to i8*), i8* %1)<br>
; CHECK: %eh.data = bitcast i8* %eh.alloc to %struct._Z4testv.ehdata*<br>
-; CHECK: %eh.obj.ptr = getelementptr inbounds %struct._Z4testv.ehdata, %struct._Z4testv.ehdata* %eh.data, i32 0, i32 1<br>
-; CHECK: %eh.obj = load i8*, i8** %eh.obj.ptr<br>
; CHECK: call void @_Z16handle_exceptionv()<br>
; CHECK: ret i8* blockaddress(@_Z4testv, %try.cont)<br>
; CHECK: }<br>
<br>
Modified: llvm/trunk/test/CodeGen/WinEH/cppeh-catch-scalar.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WinEH/cppeh-catch-scalar.ll?rev=231164&r1=231163&r2=231164&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WinEH/cppeh-catch-scalar.ll?rev=231164&r1=231163&r2=231164&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/CodeGen/WinEH/cppeh-catch-scalar.ll (original)<br>
+++ llvm/trunk/test/CodeGen/WinEH/cppeh-catch-scalar.ll Tue Mar 3 17:20:30 2015<br>
@@ -87,8 +87,6 @@ eh.resume:<br>
; CHECK: entry:<br>
; CHECK: %eh.alloc = call i8* @llvm.framerecover(i8* bitcast (void ()* @_Z4testv to i8*), i8* %1)<br>
; CHECK: %eh.data = bitcast i8* %eh.alloc to %struct._Z4testv.ehdata*<br>
-; CHECK: %eh.obj.ptr = getelementptr inbounds %struct._Z4testv.ehdata, %struct._Z4testv.ehdata* %eh.data, i32 0, i32 1<br>
-; CHECK: %eh.obj = load i8*, i8** %eh.obj.ptr<br>
; CHECK: %i = getelementptr inbounds %struct._Z4testv.ehdata, %struct._Z4testv.ehdata* %eh.data, i32 0, i32 2<br>
; CHECK: %tmp7 = load i32, i32* %i, align 4<br>
; CHECK: call void @_Z10handle_inti(i32 %tmp7)<br>
<br>
Modified: llvm/trunk/test/CodeGen/WinEH/cppeh-frame-vars.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WinEH/cppeh-frame-vars.ll?rev=231164&r1=231163&r2=231164&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WinEH/cppeh-frame-vars.ll?rev=231164&r1=231163&r2=231164&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/CodeGen/WinEH/cppeh-frame-vars.ll (original)<br>
+++ llvm/trunk/test/CodeGen/WinEH/cppeh-frame-vars.ll Tue Mar 3 17:20:30 2015<br>
@@ -181,8 +181,6 @@ eh.resume:<br>
; CHECK: entry:<br>
; CHECK: %eh.alloc = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1)<br>
; CHECK: %eh.data = bitcast i8* %eh.alloc to %"struct.\01?test@@YAXXZ.ehdata"*<br>
-; CHECK: %eh.obj.ptr = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 1<br>
-; CHECK: %eh.obj = load i8*, i8** %eh.obj.ptr<br>
; CHECK: %e = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 2<br>
; CHECK: %NumExceptions = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 3<br>
; CHECK: %ExceptionVal = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 4<br>
<br>
Modified: llvm/trunk/test/CodeGen/WinEH/cppeh-inalloca.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WinEH/cppeh-inalloca.ll?rev=231164&r1=231163&r2=231164&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WinEH/cppeh-inalloca.ll?rev=231164&r1=231163&r2=231164&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/CodeGen/WinEH/cppeh-inalloca.ll (original)<br>
+++ llvm/trunk/test/CodeGen/WinEH/cppeh-inalloca.ll Tue Mar 3 17:20:30 2015<br>
@@ -134,8 +134,6 @@ eh.resume:<br>
; CHECK: entry:<br>
; CHECK: %eh.alloc = call i8* @llvm.framerecover(i8* bitcast (i32 (<{ %struct.A }>*)* @"\01?test@@YAHUA@@@Z" to i8*), i8* %1)<br>
; CHECK: %eh.data = bitcast i8* %eh.alloc to %"struct.\01?test@@YAHUA@@@Z.ehdata"*<br>
-; CHECK: %eh.obj.ptr = getelementptr inbounds %"struct.\01?test@@YAHUA@@@Z.ehdata", %"struct.\01?test@@YAHUA@@@Z.ehdata"* %eh.data, i32 0, i32 1<br>
-; CHECK: %eh.obj = load i8*, i8** %eh.obj.ptr<br>
; CHECK: %e = getelementptr inbounds %"struct.\01?test@@YAHUA@@@Z.ehdata", %"struct.\01?test@@YAHUA@@@Z.ehdata"* %eh.data, i32 0, i32 2<br>
; CHECK: %eh.temp.alloca = getelementptr inbounds %"struct.\01?test@@YAHUA@@@Z.ehdata", %"struct.\01?test@@YAHUA@@@Z.ehdata"* %eh.data, i32 0, i32 3<br>
; CHECK: %.reload = load <{ %struct.A }>*, <{ %struct.A }>** %eh.temp.alloca<br>
<br>
Modified: llvm/trunk/test/CodeGen/WinEH/cppeh-nonalloca-frame-values.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WinEH/cppeh-nonalloca-frame-values.ll?rev=231164&r1=231163&r2=231164&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WinEH/cppeh-nonalloca-frame-values.ll?rev=231164&r1=231163&r2=231164&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/CodeGen/WinEH/cppeh-nonalloca-frame-values.ll (original)<br>
+++ llvm/trunk/test/CodeGen/WinEH/cppeh-nonalloca-frame-values.ll Tue Mar 3 17:20:30 2015<br>
@@ -189,8 +189,6 @@ eh.resume:<br>
; CHECK: entry:<br>
; CHECK: %eh.alloc = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1)<br>
; CHECK: %eh.data = bitcast i8* %eh.alloc to %"struct.\01?test@@YAXXZ.ehdata"*<br>
-; CHECK: %eh.obj.ptr = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 1<br>
-; CHECK: %eh.obj = load i8*, i8** %eh.obj.ptr<br>
; CHECK: %e = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 2<br>
; CHECK: %eh.temp.alloca = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 3<br>
; CHECK: %NumExceptions.020.reload = load i32, i32* %eh.temp.alloca<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Alexey Samsonov<br><a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a></div></div>
</div>