Extended support for native Windows C++ EH outlining

Differential Review: http://reviews.llvm.org/D7886



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231981 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Andrew Kaylor 2015-03-11 23:22:06 +00:00
parent fba5b65942
commit 1134ac4a0f
10 changed files with 1483 additions and 314 deletions

View File

@ -144,7 +144,9 @@ public:
///< Skip this instruction but continue cloning the current basic block.
SkipInstruction,
///< Skip this instruction and stop cloning the current basic block.
StopCloningBB
StopCloningBB,
///< Don't clone the terminator but clone the current block's successors.
CloneSuccessors
};
virtual ~CloningDirector() {}

File diff suppressed because it is too large Load Diff

View File

@ -392,6 +392,14 @@ void PruningFunctionCloner::CloneBlock(const BasicBlock *BB,
// terminator into the new basic block in this case.
if (Action == CloningDirector::StopCloningBB)
return;
if (Action == CloningDirector::CloneSuccessors) {
// If the director says to skip with a terminate instruction, we still
// need to clone this block's successors.
const TerminatorInst *TI = BB->getTerminator();
for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i)
ToClone.push_back(TI->getSuccessor(i));
return;
}
assert(Action != CloningDirector::SkipInstruction &&
"SkipInstruction is not valid for terminators.");
}

View File

@ -18,6 +18,12 @@
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc"
; The function entry in this case remains unchanged.
; CHECK: define void @_Z4testv() #0 {
; CHECK: entry:
; CHECK: invoke void @_Z9may_throwv()
; CHECK: to label %invoke.cont unwind label %[[LPAD_LABEL:lpad[0-9]+]]
; Function Attrs: uwtable
define void @_Z4testv() #0 {
entry:
@ -29,6 +35,16 @@ entry:
invoke.cont: ; preds = %entry
br label %try.cont
; CHECK: [[LPAD_LABEL]]:{{[ ]+}}; preds = %entry
; CHECK: [[LPAD_VAL:\%.+]] = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
; CHECK: catch i8* null
; CHECK-NOT: extractvalue { i8*, i32 }
; CHECK-NOT: store i8*
; CHECK-NOT: store i32
; CHECK-NOT: br label %catch
; CHECK: [[RECOVER:\%.+]] = call i8* (...)* @llvm.eh.actions({ i8*, i32 } [[LPAD_VAL]], i32 0, i8* null, i8* null, i8* bitcast (i8* (i8*, i8*)* @_Z4testv.catch to i8*))
; CHECK: indirectbr i8* [[RECOVER]], [label %try.cont]
lpad: ; preds = %entry
%tmp = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
catch i8* null
@ -38,18 +54,24 @@ lpad: ; preds = %entry
store i32 %tmp2, i32* %ehselector.slot
br label %catch
; CHECK-NOT: catch:
catch: ; preds = %lpad
%exn = load i8*, i8** %exn.slot
call void @llvm.eh.begincatch(i8* %exn, i8* null) #2
call void @_Z16handle_exceptionv()
br label %invoke.cont2
; CHECK-NOT: invoke.cont2:
invoke.cont2: ; preds = %catch
call void @llvm.eh.endcatch()
br label %try.cont
try.cont: ; preds = %invoke.cont2, %invoke.cont
ret void
; CHECK: }
}
; CHECK: define internal i8* @_Z4testv.catch(i8*, i8*) {

View File

@ -23,12 +23,10 @@ target triple = "x86_64-pc-windows-msvc"
; The function entry will be rewritten like this.
; CHECK: define void @_Z4testv() #0 {
; CHECK: entry:
; CHECK: %exn.slot = alloca i8*
; CHECK: %ehselector.slot = alloca i32
; CHECK: %i = alloca i32, align 4
; CHECK: call void (...)* @llvm.frameescape(i32* %i)
; CHECK: [[I_PTR:\%.+]] = alloca i32, align 4
; CHECK: call void (...)* @llvm.frameescape(i32* [[I_PTR]])
; CHECK: invoke void @_Z9may_throwv()
; CHECK: to label %invoke.cont unwind label %lpad
; CHECK: to label %invoke.cont unwind label %[[LPAD_LABEL:lpad[0-9]+]]
; Function Attrs: uwtable
define void @_Z4testv() #0 {
@ -42,6 +40,16 @@ entry:
invoke.cont: ; preds = %entry
br label %try.cont
; CHECK: [[LPAD_LABEL]]:{{[ ]+}}; preds = %entry
; CHECK: [[LPAD_VAL:\%.+]] = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
; CHECK: catch i8* bitcast (i8** @_ZTIi to i8*)
; CHECK-NOT: extractvalue { i8*, i32 }
; CHECK-NOT: store i8*
; CHECK-NOT: store i32
; CHECK-NOT: br label
; CHECK: [[RECOVER:\%.+]] = call i8* (...)* @llvm.eh.actions({ i8*, i32 } [[LPAD_VAL]], i32 0, i8* bitcast (i8** @_ZTIi to i8*), i32* %i, i8* bitcast (i8* (i8*, i8*)* @_Z4testv.catch to i8*))
; CHECK: indirectbr i8* [[RECOVER]], [label %try.cont]
lpad: ; preds = %entry
%tmp = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
catch i8* bitcast (i8** @_ZTIi to i8*)
@ -51,12 +59,16 @@ lpad: ; preds = %entry
store i32 %tmp2, i32* %ehselector.slot
br label %catch.dispatch
; CHECK-NOT: catch-dispatch:
catch.dispatch: ; preds = %lpad
%sel = load i32, i32* %ehselector.slot
%tmp3 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #3
%matches = icmp eq i32 %sel, %tmp3
br i1 %matches, label %catch, label %eh.resume
; CHECK-NOT: catch:
catch: ; preds = %catch.dispatch
%exn11 = load i8*, i8** %exn.slot
%i.i8 = bitcast i32* %i to i8*
@ -65,6 +77,8 @@ catch: ; preds = %catch.dispatch
call void @_Z10handle_inti(i32 %tmp7)
br label %invoke.cont2
; CHECK-NOT: invoke.cont2:
invoke.cont2: ; preds = %catch
call void @llvm.eh.endcatch() #3
br label %try.cont
@ -72,20 +86,24 @@ invoke.cont2: ; preds = %catch
try.cont: ; preds = %invoke.cont2, %invoke.cont
ret void
; CHECK-NOT: eh.resume:
eh.resume: ; preds = %catch.dispatch
%exn3 = load i8*, i8** %exn.slot
%sel4 = load i32, i32* %ehselector.slot
%lpad.val = insertvalue { i8*, i32 } undef, i8* %exn3, 0
%lpad.val5 = insertvalue { i8*, i32 } %lpad.val, i32 %sel4, 1
resume { i8*, i32 } %lpad.val5
; CHECK: }
}
; CHECK: define internal i8* @_Z4testv.catch(i8*, i8*) {
; CHECK: entry:
; CHECK: %i.i81 = call i8* @llvm.framerecover(i8* bitcast (void ()* @_Z4testv to i8*), i8* %1, i32 0)
; CHECK: %i = bitcast i8* %i.i81 to i32*
; CHECK: %tmp7 = load i32, i32* %i, align 4
; CHECK: call void @_Z10handle_inti(i32 %tmp7)
; CHECK: [[RECOVER_I:\%.+]] = call i8* @llvm.framerecover(i8* bitcast (void ()* @_Z4testv to i8*), i8* %1, i32 0)
; CHECK: [[I_PTR1:\%.+]] = bitcast i8* [[RECOVER_I]] to i32*
; CHECK: [[TMP:\%.+]] = load i32, i32* [[I_PTR1]], align 4
; CHECK: call void @_Z10handle_inti(i32 [[TMP]])
; CHECK: ret i8* blockaddress(@_Z4testv, %try.cont)
; CHECK: }

View File

@ -49,18 +49,16 @@ $"\01??_R0H@8" = comdat any
; The function entry should be rewritten like this.
; CHECK: define void @"\01?test@@YAXXZ"() #0 {
; CHECK: entry:
; CHECK: %NumExceptions = alloca i32, align 4
; CHECK: %ExceptionVal = alloca [10 x i32], align 16
; CHECK: %Data = alloca %struct.SomeData, align 4
; CHECK: %i = alloca i32, align 4
; CHECK: %exn.slot = alloca i8*
; CHECK: %ehselector.slot = alloca i32
; CHECK: %e = alloca i32, align 4
; CHECK: store i32 0, i32* %NumExceptions, align 4
; CHECK: %tmp = bitcast %struct.SomeData* %Data to i8*
; CHECK: call void @llvm.memset(i8* %tmp, i8 0, i64 8, i32 4, i1 false)
; CHECK: store i32 0, i32* %i, align 4
; CHECK: call void (...)* @llvm.frameescape(i32* %e, i32* %NumExceptions, [10 x i32]* %ExceptionVal, i32* %i, %struct.SomeData* %Data)
; CHECK: [[NUMEXCEPTIONS_PTR:\%.+]] = alloca i32, align 4
; CHECK: [[EXCEPTIONVAL_PTR:\%.+]] = alloca [10 x i32], align 16
; CHECK: [[DATA_PTR:\%.+]] = alloca %struct.SomeData, align 4
; CHECK: [[I_PTR:\%.+]] = alloca i32, align 4
; CHECK: [[E_PTR:\%.+]] = alloca i32, align 4
; CHECK: store i32 0, i32* [[NUMEXCEPTIONS_PTR]], align 4
; CHECK: [[TMP:\%.+]] = bitcast %struct.SomeData* [[DATA_PTR]] to i8*
; CHECK: call void @llvm.memset(i8* [[TMP]], i8 0, i64 8, i32 4, i1 false)
; CHECK: store i32 0, i32* [[I_PTR]], align 4
; CHECK: call void (...)* @llvm.frameescape(i32* [[E_PTR]], i32* [[NUMEXCEPTIONS_PTR]], [10 x i32]* [[EXCEPTIONVAL_PTR]], i32* [[I_PTR]], %struct.SomeData* [[DATA_PTR]])
; CHECK: br label %for.cond
; Function Attrs: uwtable
@ -84,6 +82,10 @@ for.cond: ; preds = %for.inc, %entry
%cmp = icmp slt i32 %tmp1, 10
br i1 %cmp, label %for.body, label %for.end
; CHECK: for.body:
; CHECK: invoke void @"\01?may_throw@@YAXXZ"()
; CHECK: to label %invoke.cont unwind label %[[LPAD_LABEL:lpad[0-9]+]]
for.body: ; preds = %for.cond
invoke void @"\01?may_throw@@YAXXZ"()
to label %invoke.cont unwind label %lpad
@ -96,6 +98,16 @@ invoke.cont: ; preds = %for.body
store i32 %add, i32* %a, align 4
br label %try.cont
; CHECK: [[LPAD_LABEL]]:{{[ ]+}}; preds = %for.body
; CHECK: [[LPAD_VAL:\%.+]] = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
; CHECK: catch i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*)
; CHECK-NOT: extractvalue { i8*, i32 }
; CHECK-NOT: store i8*
; CHECK-NOT: store i32
; CHECK-NOT: br label
; CHECK: [[RECOVER:\%.+]] = call i8* (...)* @llvm.eh.actions({ i8*, i32 } [[LPAD_VAL]], i32 0, i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*), i32* %e, i8* bitcast (i8* (i8*, i8*)* @"\01?test@@YAXXZ.catch" to i8*))
; CHECK: indirectbr i8* [[RECOVER]], [label %try.cont]
lpad: ; preds = %for.body
%tmp4 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
catch i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*)
@ -105,12 +117,16 @@ lpad: ; preds = %for.body
store i32 %tmp6, i32* %ehselector.slot
br label %catch.dispatch
; CHECK-NOT: catch.dispatch:
catch.dispatch: ; preds = %lpad
%sel = load i32, i32* %ehselector.slot
%tmp7 = call i32 @llvm.eh.typeid.for(i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*)) #1
%matches = icmp eq i32 %sel, %tmp7
br i1 %matches, label %catch, label %eh.resume
; CHECK-NOT: catch:
catch: ; preds = %catch.dispatch
%exn = load i8*, i8** %exn.slot
%e.i8 = bitcast i32* %e to i8*
@ -128,6 +144,8 @@ catch: ; preds = %catch.dispatch
%cmp1 = icmp eq i32 %tmp14, %tmp15
br i1 %cmp1, label %if.then, label %if.else
; CHECK-NOT: if.then:
if.then: ; preds = %catch
%tmp16 = load i32, i32* %e, align 4
%b = getelementptr inbounds %struct.SomeData, %struct.SomeData* %Data, i32 0, i32 1
@ -136,6 +154,8 @@ if.then: ; preds = %catch
store i32 %add2, i32* %b, align 4
br label %if.end
; CHECK-NOT: if.else:
if.else: ; preds = %catch
%tmp18 = load i32, i32* %e, align 4
%a3 = getelementptr inbounds %struct.SomeData, %struct.SomeData* %Data, i32 0, i32 0
@ -144,6 +164,8 @@ if.else: ; preds = %catch
store i32 %add4, i32* %a3, align 4
br label %if.end
; CHECK-NOT: if.end:
if.end: ; preds = %if.else, %if.then
call void @llvm.eh.endcatch() #1
br label %try.cont
@ -165,54 +187,58 @@ for.end: ; preds = %for.cond
call void @"\01?dump@@YAXPEAHHAEAUSomeData@@@Z"(i32* %arraydecay, i32 %tmp22, %struct.SomeData* dereferenceable(8) %Data)
ret void
; CHECK-NOT: eh.resume:
eh.resume: ; preds = %catch.dispatch
%exn6 = load i8*, i8** %exn.slot
%sel7 = load i32, i32* %ehselector.slot
%lpad.val = insertvalue { i8*, i32 } undef, i8* %exn6, 0
%lpad.val8 = insertvalue { i8*, i32 } %lpad.val, i32 %sel7, 1
resume { i8*, i32 } %lpad.val8
; CHECK: }
}
; The following catch handler should be outlined.
; CHECK-LABEL: define internal i8* @"\01?test@@YAXXZ.catch"(i8*, i8*) {
; CHECK: entry:
; CHECK: %e.i81 = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 0)
; CHECK: %e = bitcast i8* %e.i81 to i32*
; CHECK: %NumExceptions.i8 = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 1)
; CHECK: %NumExceptions = bitcast i8* %NumExceptions.i8 to i32*
; CHECK: %ExceptionVal.i8 = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 2)
; CHECK: %ExceptionVal = bitcast i8* %ExceptionVal.i8 to [10 x i32]*
; CHECK: %i.i8 = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 3)
; CHECK: %i = bitcast i8* %i.i8 to i32*
; CHECK: %Data.i8 = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 4)
; CHECK: %Data = bitcast i8* %Data.i8 to %struct.SomeData*
; CHECK: %tmp11 = load i32, i32* %e, align 4
; CHECK: %tmp12 = load i32, i32* %NumExceptions, align 4
; CHECK: %idxprom = sext i32 %tmp12 to i64
; CHECK: %arrayidx = getelementptr inbounds [10 x i32], [10 x i32]* %ExceptionVal, i32 0, i64 %idxprom
; CHECK: store i32 %tmp11, i32* %arrayidx, align 4
; CHECK: %tmp13 = load i32, i32* %NumExceptions, align 4
; CHECK: %inc = add nsw i32 %tmp13, 1
; CHECK: store i32 %inc, i32* %NumExceptions, align 4
; CHECK: %tmp14 = load i32, i32* %e, align 4
; CHECK: %tmp15 = load i32, i32* %i, align 4
; CHECK: %cmp1 = icmp eq i32 %tmp14, %tmp15
; CHECK: br i1 %cmp1, label %if.then, label %if.else
; CHECK: [[RECOVER_E:\%.+]] = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 0)
; CHECK: [[E_PTR1:\%.+]] = bitcast i8* [[RECOVER_E]] to i32*
; CHECK: [[RECOVER_NUMEXCEPTIONS:\%.+]] = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 1)
; CHECK: [[NUMEXCEPTIONS_PTR1:\%.+]] = bitcast i8* [[RECOVER_NUMEXCEPTIONS]] to i32*
; CHECK: [[RECOVER_EXCEPTIONVAL:\%.+]] = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 2)
; CHECK: [[EXCEPTIONVAL_PTR1:\%.+]] = bitcast i8* [[RECOVER_EXCEPTIONVAL]] to [10 x i32]*
; CHECK: [[RECOVER_I:\%.+]] = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 3)
; CHECK: [[I_PTR1:\%.+]] = bitcast i8* [[RECOVER_I]] to i32*
; CHECK: [[RECOVER_DATA:\%.+]] = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 4)
; CHECK: [[DATA_PTR1:\%.+]] = bitcast i8* [[RECOVER_DATA]] to %struct.SomeData*
; CHECK: [[TMP:\%.+]] = load i32, i32* [[E_PTR1]], align 4
; CHECK: [[TMP1:\%.+]] = load i32, i32* [[NUMEXCEPTIONS_PTR]], align 4
; CHECK: [[IDXPROM:\%.+]] = sext i32 [[TMP1]] to i64
; CHECK: [[ARRAYIDX:\%.+]] = getelementptr inbounds [10 x i32], [10 x i32]* [[EXCEPTIONVAL_PTR1]], i32 0, i64 [[IDXPROM]]
; CHECK: store i32 [[TMP]], i32* [[ARRAYIDX]], align 4
; CHECK: [[TMP2:\%.+]] = load i32, i32* [[NUMEXCEPTIONS_PTR1]], align 4
; CHECK: [[INC:\%.+]] = add nsw i32 [[TMP2]], 1
; CHECK: store i32 [[INC]], i32* [[NUMEXCEPTIONS_PTR]], align 4
; CHECK: [[TMP3:\%.+]] = load i32, i32* [[E_PTR1]], align 4
; CHECK: [[TMP4:\%.+]] = load i32, i32* [[I_PTR1]], align 4
; CHECK: [[CMP:\%.+]] = icmp eq i32 [[TMP3]], [[TMP4]]
; CHECK: br i1 [[CMP]], label %if.then, label %if.else
;
; CHECK: if.then: ; preds = %entry
; CHECK: %tmp16 = load i32, i32* %e, align 4
; CHECK: %b = getelementptr inbounds %struct.SomeData, %struct.SomeData* %Data, i32 0, i32 1
; CHECK: %tmp17 = load i32, i32* %b, align 4
; CHECK: %add2 = add nsw i32 %tmp17, %tmp16
; CHECK: store i32 %add2, i32* %b, align 4
; CHECK: [[TMP5:\%.+]] = load i32, i32* [[E_PTR1]], align 4
; CHECK: [[B_PTR:\%.+]] = getelementptr inbounds %struct.SomeData, %struct.SomeData* [[DATA_PTR1]], i32 0, i32 1
; CHECK: [[TMP6:\%.+]] = load i32, i32* [[B_PTR]], align 4
; CHECK: %add2 = add nsw i32 [[TMP6]], [[TMP5]]
; CHECK: store i32 [[ADD:\%.+]], i32* [[B_PTR]], align 4
; CHECK: br label %if.end
;
; CHECK: if.else: ; preds = %entry
; CHECK: %tmp18 = load i32, i32* %e, align 4
; CHECK: %a3 = getelementptr inbounds %struct.SomeData, %struct.SomeData* %Data, i32 0, i32 0
; CHECK: %tmp19 = load i32, i32* %a3, align 4
; CHECK: %add4 = add nsw i32 %tmp19, %tmp18
; CHECK: store i32 %add4, i32* %a3, align 4
; CHECK: [[TMP7:\%.+]] = load i32, i32* %e, align 4
; CHECK: [[A3:\%.+]] = getelementptr inbounds %struct.SomeData, %struct.SomeData* %Data, i32 0, i32 0
; CHECK: [[TMP8:\%.+]] = load i32, i32* %a3, align 4
; CHECK: [[ADD1:\%.+]] = add nsw i32 [[TMP8]], [[TMP7]]
; CHECK: store i32 [[ADD1]], i32* [[A3]], align 4
; CHECK: br label %if.end
;
; CHECK: if.end: ; preds = %if.else, %if.then
@ -220,10 +246,6 @@ eh.resume: ; preds = %catch.dispatch
; CHECK: }
; Function Attrs: nounwind
declare void @llvm.memset(i8* nocapture, i8, i64, i32, i1) #1

View File

@ -38,17 +38,15 @@ $"\01??_R0H@8" = comdat any
; The function entry should be rewritten like this.
; CHECK: define i32 @"\01?test@@YAHUA@@@Z"(<{ %struct.A }>* inalloca) #0 {
; CHECK: entry:
; CHECK: %.tmp.reg2mem = alloca <{ %struct.A }>*
; CHECK: %.tmp = select i1 true, <{ %struct.A }>* %0, <{ %struct.A }>* undef
; CHECK: store <{ %struct.A }>* %.tmp, <{ %struct.A }>** %.tmp.reg2mem
; CHECK: %retval = alloca i32, align 4
; CHECK: %exn.slot = alloca i8*
; CHECK: %ehselector.slot = alloca i32
; CHECK: %e = alloca i32, align 4
; CHECK: %cleanup.dest.slot = alloca i32
; CHECK: call void (...)* @llvm.frameescape(i32* %e, <{ %struct.A }>** %.tmp.reg2mem, i32* %retval, i32* %cleanup.dest.slot)
; CHECK: [[TMP_REGMEM:\%.+]] = alloca <{ %struct.A }>*
; CHECK: [[TMP:\%.+]] = select i1 true, <{ %struct.A }>* %0, <{ %struct.A }>* undef
; CHECK: store <{ %struct.A }>* [[TMP]], <{ %struct.A }>** [[TMP_REGMEM]]
; CHECK: [[RETVAL:\%.+]] = alloca i32, align 4
; CHECK: [[E_PTR:\%.+]] = alloca i32, align 4
; CHECK: [[CLEANUP_SLOT:\%.+]] = alloca i32
; CHECK: call void (...)* @llvm.frameescape(i32* %e, <{ %struct.A }>** [[TMP_REGMEM]], i32* [[RETVAL]], i32* [[CLEANUP_SLOT]])
; CHECK: invoke void @"\01?may_throw@@YAXXZ"()
; CHECK: to label %invoke.cont unwind label %lpad
; CHECK: to label %invoke.cont unwind label %[[LPAD_LABEL:lpad[0-9]*]]
define i32 @"\01?test@@YAHUA@@@Z"(<{ %struct.A }>* inalloca) #0 {
entry:
@ -63,6 +61,17 @@ entry:
invoke.cont: ; preds = %entry
br label %try.cont
; CHECK: [[LPAD_LABEL]]:{{[ ]+}}; preds = %entry
; CHECK: [[LPAD_VAL:\%.+]] = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
; CHECK: cleanup
; CHECK: catch i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*)
; CHECK-NOT: extractvalue { i8*, i32 }
; CHECK-NOT: store i8*
; CHECK-NOT: store i32
; CHECK-NOT: br label %catch.dispatch
; CHECK: [[RECOVER:\%recover.*]] = call i8* (...)* @llvm.eh.actions({ i8*, i32 } [[LPAD_VAL]], i32 0, i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*), i32* %e, i8* bitcast (i8* (i8*, i8*)* @"\01?test@@YAHUA@@@Z.catch" to i8*), i32 1, i8* bitcast (void (i8*, i8*)* @"\01?test@@YAHUA@@@Z.cleanup" to i8*))
; CHECK: indirectbr i8* [[RECOVER]], [label %cleanup]
lpad: ; preds = %entry
%1 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
cleanup
@ -73,12 +82,16 @@ lpad: ; preds = %entry
store i32 %3, i32* %ehselector.slot
br label %catch.dispatch
; CHECK-NOT: catch.dispatch:
catch.dispatch: ; preds = %lpad
%sel = load i32, i32* %ehselector.slot
%4 = call i32 @llvm.eh.typeid.for(i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*)) #3
%matches = icmp eq i32 %sel, %4
br i1 %matches, label %catch, label %ehcleanup
; CHECK-NOT: catch:
catch: ; preds = %catch.dispatch
%exn = load i8*, i8** %exn.slot
%e.i8 = bitcast i32* %e to i8*
@ -99,13 +112,13 @@ try.cont: ; preds = %invoke.cont
br label %cleanup
; The cleanup block should be re-written like this.
; CHECK: cleanup: ; preds = %try.cont, %catch
; CHECK: cleanup:{{[ ]+}}; preds = %[[LPAD_LABEL]], %try.cont
; CHECK-NOT: %a2 = getelementptr inbounds <{ %struct.A }>, <{ %struct.A }>* %0, i32 0, i32 0
; CHECK: %.tmp.reload1 = load volatile <{ %struct.A }>*, <{ %struct.A }>** %.tmp.reg2mem
; CHECK: %a2 = getelementptr inbounds <{ %struct.A }>, <{ %struct.A }>* %.tmp.reload1, i32 0, i32 0
; CHECK: call x86_thiscallcc void @"\01??1A@@QAE@XZ"(%struct.A* %a2) #2
; CHECK: %tmp10 = load i32, i32* %retval
; CHECK: ret i32 %tmp10
; CHECK: [[TMP_RELOAD:\%.+]] = load volatile <{ %struct.A }>*, <{ %struct.A }>** [[TMP_REGMEM]]
; CHECK: [[A2:\%.+]] = getelementptr inbounds <{ %struct.A }>, <{ %struct.A }>* [[TMP_RELOAD]], i32 0, i32 0
; CHECK: call x86_thiscallcc void @"\01??1A@@QAE@XZ"(%struct.A* [[A2]])
; CHECK: [[TMP1:\%.+]] = load i32, i32* [[RETVAL]]
; CHECK: ret i32 [[TMP1]]
cleanup: ; preds = %try.cont, %catch
%a2 = getelementptr inbounds <{ %struct.A }>, <{ %struct.A }>* %0, i32 0, i32 0
@ -113,42 +126,59 @@ cleanup: ; preds = %try.cont, %catch
%tmp10 = load i32, i32* %retval
ret i32 %tmp10
; CHECK-NOT: ehcleanup:
ehcleanup: ; preds = %catch.dispatch
%a3 = getelementptr inbounds <{ %struct.A }>, <{ %struct.A }>* %0, i32 0, i32 0
call x86_thiscallcc void @"\01??1A@@QAE@XZ"(%struct.A* %a3) #3
br label %eh.resume
; CHECK-NOT: eh.resume:
eh.resume: ; preds = %ehcleanup
%exn2 = load i8*, i8** %exn.slot
%sel3 = load i32, i32* %ehselector.slot
%lpad.val = insertvalue { i8*, i32 } undef, i8* %exn2, 0
%lpad.val4 = insertvalue { i8*, i32 } %lpad.val, i32 %sel3, 1
resume { i8*, i32 } %lpad.val4
; CHECK: }
}
; The following catch handler should be outlined.
; CHECK: define internal i8* @"\01?test@@YAHUA@@@Z.catch"(i8*, i8*) {
; CHECK: entry:
; CHECK: %e.i81 = call i8* @llvm.framerecover(i8* bitcast (i32 (<{ %struct.A }>*)* @"\01?test@@YAHUA@@@Z" to i8*), i8* %1, i32 0)
; CHECK: %e = bitcast i8* %e.i81 to i32*
; CHECK: %eh.temp.alloca.i8 = call i8* @llvm.framerecover(i8* bitcast (i32 (<{ %struct.A }>*)* @"\01?test@@YAHUA@@@Z" to i8*), i8* %1, i32 1)
; CHECK: %eh.temp.alloca = bitcast i8* %eh.temp.alloca.i8 to <{ %struct.A }>**
; CHECK: %.reload = load <{ %struct.A }>*, <{ %struct.A }>** %eh.temp.alloca
; CHECK: %retval.i8 = call i8* @llvm.framerecover(i8* bitcast (i32 (<{ %struct.A }>*)* @"\01?test@@YAHUA@@@Z" to i8*), i8* %1, i32 2)
; CHECK: %retval = bitcast i8* %retval.i8 to i32*
; CHECK: %cleanup.dest.slot.i8 = call i8* @llvm.framerecover(i8* bitcast (i32 (<{ %struct.A }>*)* @"\01?test@@YAHUA@@@Z" to i8*), i8* %1, i32 3)
; CHECK: %cleanup.dest.slot = bitcast i8* %cleanup.dest.slot.i8 to i32*
; CHECK: %e.i8 = bitcast i32* %e to i8*
; CHECK: %a = getelementptr inbounds <{ %struct.A }>, <{ %struct.A }>* %.reload, i32 0, i32 0
; CHECK: %a1 = getelementptr inbounds %struct.A, %struct.A* %a, i32 0, i32 0
; CHECK: %tmp8 = load i32, i32* %a1, align 4
; CHECK: %tmp9 = load i32, i32* %e, align 4
; CHECK: %add = add nsw i32 %tmp8, %tmp9
; CHECK: store i32 %add, i32* %retval
; CHECK: store i32 1, i32* %cleanup.dest.slot
; CHECK: [[RECOVER_E:\%.+]] = call i8* @llvm.framerecover(i8* bitcast (i32 (<{ %struct.A }>*)* @"\01?test@@YAHUA@@@Z" to i8*), i8* %1, i32 0)
; CHECK: [[E_PTR:\%.+]] = bitcast i8* [[RECOVER_E]] to i32*
; CHECK: [[RECOVER_EH_TEMP:\%.+]] = call i8* @llvm.framerecover(i8* bitcast (i32 (<{ %struct.A }>*)* @"\01?test@@YAHUA@@@Z" to i8*), i8* %1, i32 1)
; CHECK: [[EH_TEMP:\%.+]] = bitcast i8* [[RECOVER_EH_TEMP]] to <{ %struct.A }>**
; CHECK: [[TMP_RELOAD:\%.+]] = load <{ %struct.A }>*, <{ %struct.A }>** [[EH_TEMP]]
; CHECK: [[RECOVER_RETVAL:\%.+]] = call i8* @llvm.framerecover(i8* bitcast (i32 (<{ %struct.A }>*)* @"\01?test@@YAHUA@@@Z" to i8*), i8* %1, i32 2)
; CHECK: [[RETVAL1:\%.+]] = bitcast i8* [[RECOVER_RETVAL]] to i32*
; CHECK: [[RECOVER_CLEANUPSLOT:\%.+]] = call i8* @llvm.framerecover(i8* bitcast (i32 (<{ %struct.A }>*)* @"\01?test@@YAHUA@@@Z" to i8*), i8* %1, i32 3)
; CHECK: [[CLEANUPSLOT1:\%.+]] = bitcast i8* [[RECOVER_CLEANUPSLOT]] to i32*
; CHECK: [[E_I8PTR:\%.+]] = bitcast i32* [[E_PTR]] to i8*
; CHECK: [[RECOVER_A:\%.+]] = getelementptr inbounds <{ %struct.A }>, <{ %struct.A }>* [[TMP_RELOAD]], i32 0, i32 0
; CHECK: [[A1:\%.+]] = getelementptr inbounds %struct.A, %struct.A* [[RECOVER_A]], i32 0, i32 0
; CHECK: [[TMP2:\%.+]] = load i32, i32* [[A1]], align 4
; CHECK: [[TMP3:\%.+]] = load i32, i32* [[E_PTR]], align 4
; CHECK: [[ADD:\%.+]] = add nsw i32 [[TMP2]], [[TMP3]]
; CHECK: store i32 [[ADD]], i32* [[RETVAL1]]
; CHECK: store i32 1, i32* [[CLEANUPSLOT1]]
; CHECK: ret i8* blockaddress(@"\01?test@@YAHUA@@@Z", %cleanup)
; CHECK: }
; The following cleanup handler should be outlined.
; CHECK: define internal void @"\01?test@@YAHUA@@@Z.cleanup"(i8*, i8*) {
; CHECK: entry:
; CHECK: [[RECOVER_EH_TEMP1:\%.+]] = call i8* @llvm.framerecover(i8* bitcast (i32 (<{ %struct.A }>*)* @"\01?test@@YAHUA@@@Z" to i8*), i8* %1, i32 1)
; CHECK: [[EH_TEMP1:\%.+]] = bitcast i8* [[RECOVER_EH_TEMP]] to <{ %struct.A }>**
; CHECK: [[TMP_RELOAD1:\%.+]] = load <{ %struct.A }>*, <{ %struct.A }>** [[EH_TEMP1]]
; CHECK: [[A3:\%.+]] = getelementptr inbounds <{ %struct.A }>, <{ %struct.A }>* [[TMP_RELOAD1]], i32 0, i32 0
; CHECK: call x86_thiscallcc void @"\01??1A@@QAE@XZ"(%struct.A* [[A3]])
; CHECK: ret void
; CHECK: }
declare void @"\01?may_throw@@YAXXZ"() #0
declare i32 @__CxxFrameHandler3(...)

View File

@ -23,11 +23,11 @@ target triple = "x86_64-pc-windows-msvc"
; The function entry should be rewritten like this.
; CHECK: define void @_Z4testv() #0 {
; CHECK: entry:
; CHECK: %obj = alloca %class.SomeClass, align 4
; CHECK: call void @_ZN9SomeClassC1Ev(%class.SomeClass* %obj)
; CHECK: call void (...)* @llvm.frameescape(%class.SomeClass* %obj)
; CHECK: [[OBJ_PTR:\%.+]] = alloca %class.SomeClass, align 4
; CHECK: call void @_ZN9SomeClassC1Ev(%class.SomeClass* [[OBJ_PTR]])
; CHECK: call void (...)* @llvm.frameescape(%class.SomeClass* [[OBJ_PTR]])
; CHECK: invoke void @_Z9may_throwv()
; CHECK: to label %invoke.cont unwind label %lpad
; CHECK: to label %invoke.cont unwind label %[[LPAD_LABEL:lpad[0-9]+]]
; Function Attrs: uwtable
define void @_Z4testv() #0 {
@ -43,6 +43,17 @@ invoke.cont: ; preds = %entry
call void @_ZN9SomeClassD1Ev(%class.SomeClass* %obj)
ret void
; CHECK: [[LPAD_LABEL]]:{{[ ]+}}; preds = %entry
; CHECK: [[LPAD_VAL:\%.+]] = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
; CHECK: cleanup
; CHECK-NOT: extractvalue { i8*, i32 }
; CHECK-NOT: store i8*
; CHECK-NOT: store i32
; CHECK-NOT: call void @_ZN9SomeClassD1Ev
; CHECK-NOT: br label %eh.resume
; CHECK: [[RECOVER:\%.+]] = call i8* (...)* @llvm.eh.actions({ i8*, i32 } [[LPAD_VAL]], i32 1, i8* bitcast (void (i8*, i8*)* @_Z4testv.cleanup to i8*))
; CHECK: indirectbr i8* [[RECOVER]], []
lpad: ; preds = %entry
%tmp = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
cleanup
@ -53,20 +64,24 @@ lpad: ; preds = %entry
call void @_ZN9SomeClassD1Ev(%class.SomeClass* %obj)
br label %eh.resume
; CHECK-NOT: eh.resume:
eh.resume: ; preds = %lpad
%exn = load i8*, i8** %exn.slot
%sel = load i32, i32* %ehselector.slot
%lpad.val = insertvalue { i8*, i32 } undef, i8* %exn, 0
%lpad.val2 = insertvalue { i8*, i32 } %lpad.val, i32 %sel, 1
resume { i8*, i32 } %lpad.val2
; CHECK: }
}
; This cleanup handler should be outlined.
; CHECK: define internal void @_Z4testv.cleanup(i8*, i8*) {
; CHECK: entry:
; CHECK: %obj.i8 = call i8* @llvm.framerecover(i8* bitcast (void ()* @_Z4testv to i8*), i8* %1, i32 0)
; CHECK: %obj = bitcast i8* %obj.i8 to %class.SomeClass*
; CHECK: call void @_ZN9SomeClassD1Ev(%class.SomeClass* %obj)
; CHECK: [[RECOVER_OBJ:\%.+]] = call i8* @llvm.framerecover(i8* bitcast (void ()* @_Z4testv to i8*), i8* %1, i32 0)
; CHECK: [[OBJ_PTR1:\%.+]] = bitcast i8* [[RECOVER_OBJ]] to %class.SomeClass*
; CHECK: call void @_ZN9SomeClassD1Ev(%class.SomeClass* [[OBJ_PTR1]])
; CHECK: ret void
; CHECK: }

View File

@ -0,0 +1,321 @@
; RUN: opt -mtriple=x86_64-pc-windows-msvc -winehprepare -S -o - < %s | FileCheck %s
; This test is based on the following code:
;
; class Inner {
; public:
; Inner();
; ~Inner();
; };
; class Outer {
; public:
; Outer();
; ~Outer();
; };
; void test() {
; try {
; Outer outer;
; try {
; Inner inner;
; may_throw();
; } catch (int i) {
; handle_int(i);
; }
; } catch (float f) {
; handle_float(f);
; }
; done();
; }
; ModuleID = 'nested-2.cpp'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc"
%class.Outer = type { i8 }
%class.Inner = type { i8 }
@_ZTIf = external constant i8*
@_ZTIi = external constant i8*
; The function entry should be rewritten like this.
; CHECK: define void @_Z4testv() #0 {
; CHECK: entry:
; CHECK: %outer = alloca %class.Outer, align 1
; CHECK: %inner = alloca %class.Inner, align 1
; CHECK: %i = alloca i32, align 4
; CHECK: %f = alloca float, align 4
; CHECK: call void (...)* @llvm.frameescape(float* %f, i32* %i, %class.Outer* %outer, %class.Inner* %inner)
; CHECK: invoke void @_ZN5OuterC1Ev(%class.Outer* %outer)
; CHECK: to label %invoke.cont unwind label %[[LPAD_LABEL:lpad[0-9]*]]
; Function Attrs: uwtable
define void @_Z4testv() #0 {
entry:
%outer = alloca %class.Outer, align 1
%exn.slot = alloca i8*
%ehselector.slot = alloca i32
%inner = alloca %class.Inner, align 1
%i = alloca i32, align 4
%f = alloca float, align 4
invoke void @_ZN5OuterC1Ev(%class.Outer* %outer)
to label %invoke.cont unwind label %lpad
; CHECK: invoke.cont:
; CHECK: invoke void @_ZN5InnerC1Ev(%class.Inner* %inner)
; CHECK: to label %invoke.cont2 unwind label %[[LPAD1_LABEL:lpad[0-9]*]]
invoke.cont: ; preds = %entry
invoke void @_ZN5InnerC1Ev(%class.Inner* %inner)
to label %invoke.cont2 unwind label %lpad1
; CHECK: invoke.cont2:
; CHECK: invoke void @_Z9may_throwv()
; CHECK: to label %invoke.cont4 unwind label %[[LPAD3_LABEL:lpad[0-9]*]]
invoke.cont2: ; preds = %invoke.cont
invoke void @_Z9may_throwv()
to label %invoke.cont4 unwind label %lpad3
; CHECK: invoke.cont4:
; CHECK: invoke void @_ZN5InnerD1Ev(%class.Inner* %inner)
; CHECK: to label %invoke.cont5 unwind label %[[LPAD1_LABEL]]
invoke.cont4: ; preds = %invoke.cont2
invoke void @_ZN5InnerD1Ev(%class.Inner* %inner)
to label %invoke.cont5 unwind label %lpad1
; CHECK: invoke.cont5:
; CHECK: br label %try.cont
invoke.cont5: ; preds = %invoke.cont4
br label %try.cont
; CHECK: [[LPAD_LABEL]]:
; CHECK: [[LPAD_VAL:\%.+]] = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
; CHECK: catch i8* bitcast (i8** @_ZTIf to i8*)
; CHECK: [[RECOVER:\%.+]] = call i8* (...)* @llvm.eh.actions({ i8*, i32 } [[LPAD_VAL]], i32 0, i8* bitcast (i8** @_ZTIf to i8*), float* %f, i8* bitcast (i8* (i8*, i8*)* @_Z4testv.catch to i8*))
; CHECK: indirectbr i8* [[RECOVER]], [label %try.cont19]
lpad: ; preds = %try.cont, %entry
%tmp = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
catch i8* bitcast (i8** @_ZTIf to i8*)
%tmp1 = extractvalue { i8*, i32 } %tmp, 0
store i8* %tmp1, i8** %exn.slot
%tmp2 = extractvalue { i8*, i32 } %tmp, 1
store i32 %tmp2, i32* %ehselector.slot
br label %catch.dispatch11
; CHECK: [[LPAD1_LABEL]]:
; CHECK: [[LPAD1_VAL:\%.+]] = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
; CHECK: cleanup
; CHECK: catch i8* bitcast (i8** @_ZTIi to i8*)
; CHECK: catch i8* bitcast (i8** @_ZTIf to i8*)
; CHECK: [[RECOVER1:\%.+]] = call i8* (...)* @llvm.eh.actions({ i8*, i32 } [[LPAD1_VAL]], i32 0, i8* bitcast (i8** @_ZTIi to i8*), i32* %i, i8* bitcast (i8* (i8*, i8*)* @_Z4testv.catch1 to i8*), i32 1, i8* bitcast (void (i8*, i8*)* @_Z4testv.cleanup to i8*), i32 0, i8* bitcast (i8** @_ZTIf to i8*), float* %f, i8* bitcast (i8* (i8*, i8*)* @_Z4testv.catch to i8*))
; CHECK: indirectbr i8* [[RECOVER1]], [label %try.cont, label %try.cont19]
lpad1: ; preds = %invoke.cont4, %invoke.cont
%tmp3 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
cleanup
catch i8* bitcast (i8** @_ZTIi to i8*)
catch i8* bitcast (i8** @_ZTIf to i8*)
%tmp4 = extractvalue { i8*, i32 } %tmp3, 0
store i8* %tmp4, i8** %exn.slot
%tmp5 = extractvalue { i8*, i32 } %tmp3, 1
store i32 %tmp5, i32* %ehselector.slot
br label %catch.dispatch
; CHECK: [[LPAD3_LABEL]]:
; CHECK: [[LPAD3_VAL:\%.+]] = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
; CHECK: cleanup
; CHECK: catch i8* bitcast (i8** @_ZTIi to i8*)
; CHECK: catch i8* bitcast (i8** @_ZTIf to i8*)
; CHECK-NOT: extractvalue { i8*, i32 }
; CHECK-NOT: store i8*
; CHECK-NOT: store i32
; CHECK-NOT: call void @_ZN5InnerD1Ev(%class.Inner* %inner)
; CHECK: [[RECOVER3:\%.+]] = call i8* (...)* @llvm.eh.actions({ i8*, i32 } [[LPAD3_VAL]], i32 1, i8* bitcast (void (i8*, i8*)* @_Z4testv.cleanup2 to i8*), i32 0, i8* bitcast (i8** @_ZTIi to i8*), i32* %i, i8* bitcast (i8* (i8*, i8*)* @_Z4testv.catch1 to i8*), i32 1, i8* bitcast (void (i8*, i8*)* @_Z4testv.cleanup to i8*), i32 0, i8* bitcast (i8** @_ZTIf to i8*), float* %f, i8* bitcast (i8* (i8*, i8*)* @_Z4testv.catch to i8*))
; CHECK: indirectbr i8* [[RECOVER3]], [label %try.cont, label %try.cont19]
lpad3: ; preds = %invoke.cont2
%tmp6 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
cleanup
catch i8* bitcast (i8** @_ZTIi to i8*)
catch i8* bitcast (i8** @_ZTIf to i8*)
%tmp7 = extractvalue { i8*, i32 } %tmp6, 0
store i8* %tmp7, i8** %exn.slot
%tmp8 = extractvalue { i8*, i32 } %tmp6, 1
store i32 %tmp8, i32* %ehselector.slot
call void @_ZN5InnerD1Ev(%class.Inner* %inner)
br label %catch.dispatch
; CHECK-NOT: catch.dispatch:
catch.dispatch: ; preds = %lpad3, %lpad1
%sel = load i32, i32* %ehselector.slot
%tmp9 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #4
%matches = icmp eq i32 %sel, %tmp9
br i1 %matches, label %catch, label %ehcleanup
; CHECK-NOT: catch:
catch: ; preds = %catch.dispatch
%exn = load i8*, i8** %exn.slot
%i.i8 = bitcast i32* %i to i8*
call void @llvm.eh.begincatch(i8* %exn, i8* %i.i8) #4
%tmp13 = load i32, i32* %i, align 4
invoke void @_Z10handle_inti(i32 %tmp13)
to label %invoke.cont8 unwind label %lpad7
; CHECK-NOT: invoke.cont8:
invoke.cont8: ; preds = %catch
call void @llvm.eh.endcatch() #4
br label %try.cont
; CHECK: try.cont:
; CHECK: invoke void @_ZN5OuterD1Ev(%class.Outer* %outer)
; CHECK: to label %invoke.cont9 unwind label %[[LPAD_LABEL]]
try.cont: ; preds = %invoke.cont8, %invoke.cont5
invoke void @_ZN5OuterD1Ev(%class.Outer* %outer)
to label %invoke.cont9 unwind label %lpad
invoke.cont9: ; preds = %try.cont
br label %try.cont19
; CHECK-NOT: lpad7:
lpad7: ; preds = %catch
%tmp14 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
cleanup
catch i8* bitcast (i8** @_ZTIf to i8*)
%tmp15 = extractvalue { i8*, i32 } %tmp14, 0
store i8* %tmp15, i8** %exn.slot
%tmp16 = extractvalue { i8*, i32 } %tmp14, 1
store i32 %tmp16, i32* %ehselector.slot
call void @llvm.eh.endcatch() #4
br label %ehcleanup
; CHECK-NOT: ehcleanup: ; preds = %lpad7, %catch.dispatch
ehcleanup: ; preds = %lpad7, %catch.dispatch
call void @_ZN5OuterD1Ev(%class.Outer* %outer)
br label %catch.dispatch11
; CHECK-NOT: catch.dispatch11:
catch.dispatch11: ; preds = %ehcleanup, %lpad
%sel12 = load i32, i32* %ehselector.slot
%tmp17 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIf to i8*)) #4
%matches13 = icmp eq i32 %sel12, %tmp17
br i1 %matches13, label %catch14, label %eh.resume
; CHECK-NOT: catch14:
catch14: ; preds = %catch.dispatch11
%exn15 = load i8*, i8** %exn.slot
%f.i8 = bitcast float* %f to i8*
call void @llvm.eh.begincatch(i8* %exn15, i8* %f.i8) #4
%tmp21 = load float, float* %f, align 4
call void @_Z12handle_floatf(float %tmp21)
call void @llvm.eh.endcatch() #4
br label %try.cont19
try.cont19: ; preds = %catch14, %invoke.cont9
call void @_Z4donev()
ret void
; CHECK-NOT: eh.resume:
eh.resume: ; preds = %catch.dispatch11
%exn20 = load i8*, i8** %exn.slot
%sel21 = load i32, i32* %ehselector.slot
%lpad.val = insertvalue { i8*, i32 } undef, i8* %exn20, 0
%lpad.val22 = insertvalue { i8*, i32 } %lpad.val, i32 %sel21, 1
resume { i8*, i32 } %lpad.val22
; CHECK: }
}
; This catch handler should be outlined.
; CHECK: define internal i8* @_Z4testv.catch(i8*, i8*) {
; CHECK: entry:
; CHECK: [[RECOVER_F:\%.+]] = call i8* @llvm.framerecover(i8* bitcast (void ()* @_Z4testv to i8*), i8* %1, i32 0)
; CHECK: [[F_PTR:\%.+]] = bitcast i8* [[RECOVER_F]] to float*
; CHECK: [[TMP:\%.+]] = load float, float* [[F_PTR]], align 4
; CHECK: call void @_Z12handle_floatf(float [[TMP]])
; CHECK: ret i8* blockaddress(@_Z4testv, %try.cont19)
; CHECK: }
; This catch handler should be outlined.
; CHECK: define internal i8* @_Z4testv.catch1(i8*, i8*) {
; CHECK: entry:
; CHECK: [[RECOVER_I:\%.+]] = call i8* @llvm.framerecover(i8* bitcast (void ()* @_Z4testv to i8*), i8* %1, i32 1)
; CHECK: [[I_PTR:\%.+]] = bitcast i8* [[RECOVER_I]] to i32*
; CHECK: [[TMP1:\%.+]] = load i32, i32* [[I_PTR]], align 4
; CHECK: invoke void @_Z10handle_inti(i32 [[TMP1]])
; CHECK: to label %invoke.cont8 unwind label %[[LPAD7_LABEL:lpad[0-9]*]]
;
; CHECK: invoke.cont8: ; preds = %entry
; CHECK: ret i8* blockaddress(@_Z4testv, %try.cont)
;
; CHECK: [[LPAD7_LABEL]]:{{[ ]+}}; preds = %entry
; CHECK: [[LPAD7_VAL:\%.+]] = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
; (FIXME) The nested handler body isn't being populated yet.
; CHECK: }
; This cleanup handler should be outlined.
; CHECK: define internal void @_Z4testv.cleanup(i8*, i8*) {
; CHECK: entry:
; CHECK: [[RECOVER_OUTER:\%.+]] = call i8* @llvm.framerecover(i8* bitcast (void ()* @_Z4testv to i8*), i8* %1, i32 2)
; CHECK: [[OUTER_PTR:\%.+]] = bitcast i8* [[RECOVER_OUTER]] to %class.Outer*
; CHECK: call void @_ZN5OuterD1Ev(%class.Outer* [[OUTER_PTR]])
; CHECK: ret void
; CHECK: }
; This cleanup handler should be outlined.
; CHECK: define internal void @_Z4testv.cleanup2(i8*, i8*) {
; CHECK: entry:
; CHECK: [[RECOVER_INNER:\%.+]] = call i8* @llvm.framerecover(i8* bitcast (void ()* @_Z4testv to i8*), i8* %1, i32 3)
; CHECK: [[INNER_PTR:\%.+]] = bitcast i8* [[RECOVER_INNER]] to %class.Inner*
; CHECK: call void @_ZN5InnerD1Ev(%class.Inner* [[INNER_PTR]])
; CHECK: ret void
; CHECK: }
declare void @_ZN5OuterC1Ev(%class.Outer*) #1
declare i32 @__CxxFrameHandler3(...)
declare void @_ZN5InnerC1Ev(%class.Inner*) #1
declare void @_Z9may_throwv() #1
declare void @_ZN5InnerD1Ev(%class.Inner*) #1
declare void @llvm.eh.begincatch(i8*, i8*)
; Function Attrs: nounwind readnone
declare i32 @llvm.eh.typeid.for(i8*) #3
declare void @_Z10handle_inti(i32) #1
declare void @llvm.eh.endcatch()
declare void @_ZN5OuterD1Ev(%class.Outer*) #1
declare void @_Z12handle_floatf(float) #1
declare void @_Z4donev() #1
attributes #0 = { uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #2 = { noinline noreturn nounwind }
attributes #3 = { nounwind readnone }
attributes #4 = { nounwind }
attributes #5 = { noreturn nounwind }
!llvm.ident = !{!0}
!0 = !{!"clang version 3.7.0 (trunk 226027)"}

View File

@ -53,24 +53,24 @@ $"\01??_R0H@8" = comdat any
; The function entry should be rewritten like this.
; CHECK: define void @"\01?test@@YAXXZ"() #0 {
; CHECK: entry:
; CHECK: %NumExceptions.020.reg2mem = alloca i32
; CHECK: %i.019.reg2mem = alloca i32
; CHECK: %e = alloca i32, align 4
; CHECK: %ExceptionVal = alloca [10 x i32], align 16
; CHECK: %Data = alloca i64, align 8
; CHECK: %tmpcast = bitcast i64* %Data to %struct.SomeData*
; CHECK: %0 = bitcast [10 x i32]* %ExceptionVal to i8*
; CHECK: call void @llvm.lifetime.start(i64 40, i8* %0) #1
; CHECK: store i64 0, i64* %Data, align 8
; CHECK: %a.reg2mem = alloca i32*
; CHECK: %a = bitcast i64* %Data to i32*
; CHECK: store i32* %a, i32** %a.reg2mem
; CHECK: %b.reg2mem = alloca i32*
; CHECK: %b = getelementptr inbounds %struct.SomeData, %struct.SomeData* %tmpcast, i64 0, i32 1
; CHECK: store i32* %b, i32** %b.reg2mem
; CHECK: store i32 0, i32* %NumExceptions.020.reg2mem
; CHECK: store i32 0, i32* %i.019.reg2mem
; CHECK: call void (...)* @llvm.frameescape(i32* %e, i32* %NumExceptions.020.reg2mem, [10 x i32]* %ExceptionVal, i32* %i.019.reg2mem, i32** %a.reg2mem, i32** %b.reg2mem)
; CHECK: [[NUMEXCEPTIONS_REGMEM:\%.+]] = alloca i32
; CHECK: [[I_REGMEM:\%.+]] = alloca i32
; CHECK: [[E_PTR:\%.+]] = alloca i32, align 4
; CHECK: [[EXCEPTIONVAL:\%.+]] = alloca [10 x i32], align 16
; CHECK: [[DATA_PTR:\%.+]] = alloca i64, align 8
; CHECK: [[TMPCAST:\%.+]] = bitcast i64* [[DATA_PTR]] to %struct.SomeData*
; CHECK: [[TMP:\%.+]] = bitcast [10 x i32]* [[EXCEPTIONVAL]] to i8*
; CHECK: call void @llvm.lifetime.start(i64 40, i8* [[TMP]])
; CHECK: store i64 0, i64* [[DATA_PTR]], align 8
; CHECK: [[A_REGMEM:\%.+]] = alloca i32*
; CHECK: [[A_PTR:\%.+]] = bitcast i64* [[DATA_PTR]] to i32*
; CHECK: store i32* [[A_PTR]], i32** [[A_REGMEM]]
; CHECK: [[B_PTR:\%.+]] = getelementptr inbounds %struct.SomeData, %struct.SomeData* [[TMPCAST]], i64 0, i32 1
; CHECK: [[B_REGMEM:\%.+]] = alloca i32*
; CHECK: store i32* [[B_PTR]], i32** [[B_REGMEM]]
; CHECK: store i32 0, i32* [[NUMEXCEPTIONS_REGMEM]]
; CHECK: store i32 0, i32* [[I_REGMEM]]
; CHECK: call void (...)* @llvm.frameescape(i32* %e, i32* %NumExceptions.020.reg2mem, [10 x i32]* [[EXCEPTIONVAL]], i32* [[I_REGMEM]], i32** [[A_REGMEM]], i32** [[B_REGMEM]])
; CHECK: br label %for.body
; Function Attrs: uwtable
@ -88,10 +88,10 @@ entry:
br label %for.body
; CHECK: for.body:
; CHECK-NOT: %NumExceptions.020 = phi i32 [ 0, %entry ], [ %NumExceptions.1, %try.cont ]
; CHECK-NOT: %i.019 = phi i32 [ 0, %entry ], [ %inc5, %try.cont ]
; CHECK: %i.019.reload = load i32, i32* %i.019.reg2mem
; CHECK: %NumExceptions.020.reload = load i32, i32* %NumExceptions.020.reg2mem
; CHECK-NOT: phi i32 [ 0, %entry ], [ {{\%NumExceptions.*}}, %try.cont ]
; CHECK-NOT: phi i32 [ 0, %entry ], [ {{\%inc.*}}, %try.cont ]
; CHECK: [[I_RELOAD:\%.+]] = load i32, i32* [[I_REGMEM]]
; CHECK: [[NUMEXCEPTIONS_RELOAD:\%.+]] = load i32, i32* [[NUMEXCEPTIONS_REGMEM]]
for.body: ; preds = %entry, %try.cont
%NumExceptions.020 = phi i32 [ 0, %entry ], [ %NumExceptions.1, %try.cont ]
%i.019 = phi i32 [ 0, %entry ], [ %inc5, %try.cont ]
@ -99,14 +99,11 @@ for.body: ; preds = %entry, %try.cont
to label %invoke.cont unwind label %lpad
; CHECK: invoke.cont: ; preds = %for.body
; CHECK-NOT: %1 = load i32, i32* %a, align 8, !tbaa !2
; CHECK-NOT: %add = add nsw i32 %1, %i.019
; CHECK-NOT: store i32 %add, i32* %a, align 8, !tbaa !2
; CHECK: %a.reload3 = load volatile i32*, i32** %a.reg2mem
; CHECK: %1 = load i32, i32* %a.reload3, align 8, !tbaa !2
; CHECK: %add = add nsw i32 %1, %i.019.reload
; CHECK: %a.reload2 = load volatile i32*, i32** %a.reg2mem
; CHECK: store i32 %add, i32* %a.reload2, align 8, !tbaa !2
; CHECK: [[A_RELOAD:\%.+]] = load volatile i32*, i32** [[A_REGMEM]]
; CHECK: [[TMP1:\%.+]] = load i32, i32* [[A_RELOAD]], align 8
; CHECK: [[ADD:\%.+]] = add nsw i32 [[TMP1]], [[I_RELOAD]]
; CHECK: [[A_RELOAD1:\%.+]] = load volatile i32*, i32** [[A_REGMEM]]
; CHECK: store i32 [[ADD]], i32* [[A_RELOAD1]], align 8
; CHECK: br label %try.cont
invoke.cont: ; preds = %for.body
%1 = load i32, i32* %a, align 8, !tbaa !2
@ -114,6 +111,16 @@ invoke.cont: ; preds = %for.body
store i32 %add, i32* %a, align 8, !tbaa !2
br label %try.cont
; CHECK: [[LPAD_LABEL:lpad[0-9]*]]:{{[ ]+}}; preds = %for.body
; CHECK: [[LPAD_VAL:\%.+]] = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
; CHECK: catch i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*)
; CHECK-NOT: extractvalue { i8*, i32 }
; CHECK-NOT: tail call i32 @llvm.eh.typeid.for(i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*))
; CHECK-NOT: icmp eq i32
; CHECK-NOT: br i1
; CHECK: [[RECOVER:\%.+]] = call i8* (...)* @llvm.eh.actions({ i8*, i32 } [[LPAD_VAL]], i32 0, i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*), i32* %e, i8* bitcast (i8* (i8*, i8*)* @"\01?test@@YAXXZ.catch" to i8*))
; CHECK: indirectbr i8* [[RECOVER]], [label %try.cont]
lpad: ; preds = %for.body
%2 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
catch i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*)
@ -122,6 +129,8 @@ lpad: ; preds = %for.body
%matches = icmp eq i32 %3, %4
br i1 %matches, label %catch, label %eh.resume
; CHECK-NOT: catch:
catch: ; preds = %lpad
%5 = extractvalue { i8*, i32 } %2, 0
%e.i8 = bitcast i32* %e to i8*
@ -134,32 +143,36 @@ catch: ; preds = %lpad
%cmp1 = icmp eq i32 %tmp8, %i.019
br i1 %cmp1, label %if.then, label %if.else
; CHECK-NOT: if.then:
if.then: ; preds = %catch
%tmp9 = load i32, i32* %b, align 4, !tbaa !8
%add2 = add nsw i32 %tmp9, %i.019
store i32 %add2, i32* %b, align 4, !tbaa !8
br label %if.end
; CHECK-NOT: if.else:
if.else: ; preds = %catch
%tmp10 = load i32, i32* %a, align 8, !tbaa !2
%add4 = add nsw i32 %tmp10, %tmp8
store i32 %add4, i32* %a, align 8, !tbaa !2
br label %if.end
; CHECK-NOT: if.end:
if.end: ; preds = %if.else, %if.then
tail call void @llvm.eh.endcatch() #1
br label %try.cont
; CHECK: try.cont: ; preds = %if.end, %invoke.cont
; CHECK-NOT: %NumExceptions.1 = phi i32 [ %NumExceptions.020, %invoke.cont ], [ %inc, %if.end ]
; CHECK: %NumExceptions.1 = phi i32 [ %NumExceptions.020.reload, %invoke.cont ], [ %inc, %if.end ]
; CHECK: tail call void @"\01?does_not_throw@@YAXH@Z"(i32 %NumExceptions.1)
; CHECK-NOT: %inc5 = add nuw nsw i32 %i.019, 1
; CHECK: %inc5 = add nuw nsw i32 %i.019.reload, 1
; CHECK: %cmp = icmp slt i32 %inc5, 10
; CHECK: store i32 %NumExceptions.1, i32* %NumExceptions.020.reg2mem
; CHECK: store i32 %inc5, i32* %i.019.reg2mem
; CHECK: br i1 %cmp, label %for.body, label %for.end
; CHECK: try.cont:{{[ ]+}}; preds = %[[LPAD_LABEL]], %invoke.cont
; CHECK-NOT: phi i32
; CHECK: tail call void @"\01?does_not_throw@@YAXH@Z"(i32 [[NUMEXCEPTIONS_RELOAD]])
; CHECK: [[INC:\%.+]] = add nuw nsw i32 [[I_RELOAD]], 1
; CHECK: [[CMP:\%.+]] = icmp slt i32 [[INC]], 10
; CHECK: store i32 [[NUMEXCEPTIONS_RELOAD]], i32* [[NUMEXCEPTIONS_REGMEM]]
; CHECK: store i32 [[INC]], i32* [[I_REGMEM]]
; CHECK: br i1 [[CMP]], label %for.body, label %for.end
try.cont: ; preds = %if.end, %invoke.cont
%NumExceptions.1 = phi i32 [ %NumExceptions.020, %invoke.cont ], [ %inc, %if.end ]
@ -183,44 +196,44 @@ eh.resume: ; preds = %lpad
; The following catch handler should be outlined.
; CHECK: define internal i8* @"\01?test@@YAXXZ.catch"(i8*, i8*) {
; CHECK: entry:
; CHECK: %e.i84 = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 0)
; CHECK: %e = bitcast i8* %e.i84 to i32*
; CHECK: %eh.temp.alloca.i8 = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 1)
; CHECK: %eh.temp.alloca = bitcast i8* %eh.temp.alloca.i8 to i32*
; CHECK: %NumExceptions.020.reload = load i32, i32* %eh.temp.alloca
; CHECK: %ExceptionVal.i8 = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 2)
; CHECK: %ExceptionVal = bitcast i8* %ExceptionVal.i8 to [10 x i32]*
; CHECK: %eh.temp.alloca1.i8 = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 3)
; CHECK: %eh.temp.alloca1 = bitcast i8* %eh.temp.alloca1.i8 to i32*
; CHECK: %i.019.reload = load i32, i32* %eh.temp.alloca1
; CHECK: %eh.temp.alloca2.i8 = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 4)
; CHECK: %eh.temp.alloca2 = bitcast i8* %eh.temp.alloca2.i8 to i32**
; CHECK: %a.reload = load i32*, i32** %eh.temp.alloca2
; CHECK: %eh.temp.alloca3.i8 = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 5)
; CHECK: %eh.temp.alloca3 = bitcast i8* %eh.temp.alloca3.i8 to i32**
; CHECK: %b.reload = load i32*, i32** %eh.temp.alloca3
; CHECK: %e.i8 = bitcast i32* %e to i8*
; CHECK: %tmp8 = load i32, i32* %e, align 4, !tbaa !7
; CHECK: %idxprom = sext i32 %NumExceptions.020.reload to i64
; CHECK: %arrayidx = getelementptr inbounds [10 x i32], [10 x i32]* %ExceptionVal, i64 0, i64 %idxprom
; CHECK: store i32 %tmp8, i32* %arrayidx, align 4, !tbaa !7
; CHECK: %inc = add nsw i32 %NumExceptions.020.reload, 1
; CHECK: %cmp1 = icmp eq i32 %tmp8, %i.019.reload
; CHECK: br i1 %cmp1, label %if.then, label %if.else
; CHECK: [[RECOVER_E:\%.+]] = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 0)
; CHECK: [[E_PTR:\%.+]] = bitcast i8* [[RECOVER_E]] to i32*
; CHECK: [[RECOVER_EH_TEMP:\%.+]] = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 1)
; CHECK: [[EH_TEMP:\%.+]] = bitcast i8* [[RECOVER_EH_TEMP]] to i32*
; CHECK: [[NUMEXCEPTIONS_RELOAD:\%.+]] = load i32, i32* [[EH_TEMP]]
; CHECK: [[RECOVER_EXCEPTIONVAL:\%.+]] = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 2)
; CHECK: [[EXCEPTIONVAL:\%.+]] = bitcast i8* [[RECOVER_EXCEPTIONVAL]] to [10 x i32]*
; CHECK: [[RECOVER_EH_TEMP1:\%.+]] = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 3)
; CHECK: [[EH_TEMP1:\%.+]] = bitcast i8* [[RECOVER_EH_TEMP1]] to i32*
; CHECK: [[I_RELOAD:\%.+]] = load i32, i32* [[EH_TEMP1]]
; CHECK: [[RECOVER_EH_TEMP2:\%.+]] = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 4)
; CHECK: [[EH_TEMP2:\%.+]] = bitcast i8* [[RECOVER_EH_TEMP2]] to i32**
; CHECK: [[A_RELOAD:\%.+]] = load i32*, i32** [[EH_TEMP2]]
; CHECK: [[RECOVER_EH_TEMP3:\%.+]] = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 5)
; CHECK: [[EH_TEMP3:\%.+]] = bitcast i8* [[RECOVER_EH_TEMP3]] to i32**
; CHECK: [[B_RELOAD:\%.+]] = load i32*, i32** [[EH_TEMP3]]
; CHECK: [[E_I8PTR:\%.+]] = bitcast i32* [[E_PTR]] to i8*
; CHECK: [[TMP:\%.+]] = load i32, i32* [[E_PTR]], align 4
; CHECK: [[IDXPROM:\%.+]] = sext i32 [[NUMEXCEPTIONS_RELOAD]] to i64
; CHECK: [[ARRAYIDX:\%.+]] = getelementptr inbounds [10 x i32], [10 x i32]* [[EXCEPTIONVAL]], i64 0, i64 [[IDXPROM]]
; CHECK: store i32 [[TMP]], i32* [[ARRAYIDX]], align 4
; CHECK: [[INC:\%.+]] = add nsw i32 [[NUMEXCEPTIONS_RELOAD]], 1
; CHECK: [[CMP:\%.+]] = icmp eq i32 [[TMP]], [[I_RELOAD]]
; CHECK: br i1 [[CMP]], label %if.then, label %if.else
;
; CHECK: if.then: ; preds = %entry
; CHECK: %tmp9 = load i32, i32* %b.reload, align 4, !tbaa !8
; CHECK: %add2 = add nsw i32 %tmp9, %i.019.reload
; CHECK: store i32 %add2, i32* %b.reload, align 4, !tbaa !8
; CHECK: if.then:{{[ ]+}}; preds = %entry
; CHECK: [[TMP1:\%.+]] = load i32, i32* [[B_RELOAD]], align 4
; CHECK: [[ADD:\%.+]] = add nsw i32 [[TMP1]], [[I_RELOAD]]
; CHECK: store i32 [[ADD]], i32* [[B_RELOAD]], align 4
; CHECK: br label %if.end
;
; CHECK: if.else: ; preds = %entry
; CHECK: %tmp10 = load i32, i32* %a.reload, align 8, !tbaa !2
; CHECK: %add4 = add nsw i32 %tmp10, %tmp8
; CHECK: store i32 %add4, i32* %a.reload, align 8, !tbaa !2
; CHECK: if.else:{{[ ]+}}; preds = %entry
; CHECK: [[TMP2:\%.+]] = load i32, i32* [[A_RELOAD]], align 8
; CHECK: [[ADD2:\%.+]] = add nsw i32 [[TMP2]], [[TMP]]
; CHECK: store i32 [[ADD2]], i32* [[A_RELOAD]], align 8
; CHECK: br label %if.end
;
; CHECK: if.end: ; preds = %if.else, %if.then
; CHECK: if.end:{{[ ]+}}; preds = %if.else, %if.then
; CHECK: ret i8* blockaddress(@"\01?test@@YAXXZ", %try.cont)
; CHECK: }