llvm.org GIT mirror llvm / 9c28314
Make llvm.eh.begincatch use an outparam Ultimately, __CxxFrameHandler3 needs us to put a stack offset in a table, and it will take responsibility for copying the exception object into that slot. Modelling the exception object as an SSA value returned by begincatch isn't going to work in general, so make it use an output parameter. Reviewers: andrew.w.kaylor Differential Revision: http://reviews.llvm.org/D7920 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231086 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Kleckner 4 years ago
9 changed file(s) with 112 addition(s) and 123 deletion(s). Raw diff Collapse all Expand all
441441
442442 .. code-block:: llvm
443443
444 i8* @llvm.eh.begincatch(i8* %exn)
444 void @llvm.eh.begincatch(i8* %ehptr, i8* %ehobj)
445445
446446
447447 This intrinsic marks the beginning of catch handling code within the blocks
449449 depends on the compilation target and the personality function associated
450450 with the ``landingpad`` instruction.
451451
452 The argument to this intrinsic is a pointer that was previously extracted from
453 the aggregate return value of the ``landingpad`` instruction. The return
454 value of the intrinsic is a pointer to the exception object to be used by the
455 catch code. This pointer is returned as an ``i8*`` value, but the actual type
456 of the object will depend on the exception that was thrown.
452 The first argument to this intrinsic is a pointer that was previously extracted
453 from the aggregate return value of the ``landingpad`` instruction. The second
454 argument to the intrinsic is a pointer to stack space where the exception object
455 should be stored. The runtime handles the details of copying the exception
456 object into the slot. If the second parameter is null, no copy occurs.
457457
458458 Uses of this intrinsic are generated by the C++ front-end. Many targets will
459459 use implementation-specific functions (such as ``__cxa_begin_catch``) instead
411411 def int_eh_return_i64 : Intrinsic<[], [llvm_i64_ty, llvm_ptr_ty]>;
412412
413413 // eh.begincatch takes a pointer returned by a landingpad instruction and
414 // returns the exception object pointer for the exception to be handled.
415 def int_eh_begincatch : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty]>;
414 // copies the exception object into the memory pointed to by the second
415 // parameter. If the second parameter is null, no copy occurs.
416 def int_eh_begincatch : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty],
417 [NoCapture<0>, NoCapture<1>]>;
416418 def int_eh_endcatch : Intrinsic<[], []>;
417419
418420 // __builtin_unwind_init is an undocumented GCC intrinsic that causes all
44
55 target triple = "x86_64-pc-windows-msvc"
66
7 declare i8* @llvm.eh.begincatch(i8*)
7 declare void @llvm.eh.begincatch(i8*, i8*)
88
99 declare void @llvm.eh.endcatch()
1010
2626 br i1 %matches, label %catch, label %eh.resume
2727
2828 catch: ; preds = %lpad
29 %2 = call i8* @llvm.eh.begincatch(i8* %exn)
29 call void @llvm.eh.begincatch(i8* %exn, i8* null)
3030 call void @_Z10handle_intv()
3131 br label %invoke.cont2
3232
7676 catch: ; preds = %lpad, %lpad1
7777 %exn2 = phi i8* [%exn, %lpad], [%exn1, %lpad1]
7878 %sel2 = phi i32 [%sel, %lpad], [%sel1, %lpad1]
79 %3 = call i8* @llvm.eh.begincatch(i8* %exn2)
79 call void @llvm.eh.begincatch(i8* %exn2, i8* null)
8080 call void @_Z10handle_intv()
8181 %matches1 = icmp eq i32 %sel2, 0
8282 br i1 %matches1, label %invoke.cont2, label %invoke.cont3
55
66 target triple = "x86_64-pc-windows-msvc"
77
8 declare i8* @llvm.eh.begincatch(i8*)
8 declare void @llvm.eh.begincatch(i8*, i8*)
99
1010 declare void @llvm.eh.endcatch()
1111
1414 ; Function Attrs: uwtable
1515 define void @test_missing_endcatch() {
1616 ; CHECK: Some paths from llvm.eh.begincatch may not reach llvm.eh.endcatch
17 ; CHECK-NEXT: %2 = call i8* @llvm.eh.begincatch(i8* %exn)
18 entry:
19 invoke void @_Z9may_throwv()
20 to label %try.cont unwind label %lpad
21
22 lpad: ; preds = %entry
23 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
24 catch i8* bitcast (i8** @_ZTIi to i8*)
25 %exn = extractvalue { i8*, i32 } %0, 0
26 %sel = extractvalue { i8*, i32 } %0, 1
27 %1 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
28 %matches = icmp eq i32 %sel, %1
29 br i1 %matches, label %catch, label %eh.resume
30
31 catch: ; preds = %lpad
32 %2 = call i8* @llvm.eh.begincatch(i8* %exn)
17 ; CHECK-NEXT: call void @llvm.eh.begincatch(i8* %exn, i8* null)
18 entry:
19 invoke void @_Z9may_throwv()
20 to label %try.cont unwind label %lpad
21
22 lpad: ; preds = %entry
23 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
24 catch i8* bitcast (i8** @_ZTIi to i8*)
25 %exn = extractvalue { i8*, i32 } %0, 0
26 %sel = extractvalue { i8*, i32 } %0, 1
27 %1 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
28 %matches = icmp eq i32 %sel, %1
29 br i1 %matches, label %catch, label %eh.resume
30
31 catch: ; preds = %lpad
32 call void @llvm.eh.begincatch(i8* %exn, i8* null)
3333 call void @_Z10handle_intv()
3434 br label %invoke.cont2
3535
7878 ; Function Attrs: uwtable
7979 define void @test_multiple_begin() {
8080 ; CHECK: llvm.eh.begincatch may be called a second time before llvm.eh.endcatch
81 ; CHECK-NEXT: %2 = call i8* @llvm.eh.begincatch(i8* %exn)
82 ; CHECK-NEXT: %3 = call i8* @llvm.eh.begincatch(i8* %exn)
83 entry:
84 invoke void @_Z9may_throwv()
85 to label %try.cont unwind label %lpad
86
87 lpad: ; preds = %entry
88 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
89 catch i8* bitcast (i8** @_ZTIi to i8*)
90 %exn = extractvalue { i8*, i32 } %0, 0
91 %sel = extractvalue { i8*, i32 } %0, 1
92 %1 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
93 %matches = icmp eq i32 %sel, %1
94 br i1 %matches, label %catch, label %eh.resume
95
96 catch: ; preds = %lpad
97 %2 = call i8* @llvm.eh.begincatch(i8* %exn)
98 call void @_Z10handle_intv()
99 br label %invoke.cont2
100
101 invoke.cont2: ; preds = %catch
102 %3 = call i8* @llvm.eh.begincatch(i8* %exn)
81 ; CHECK-NEXT: call void @llvm.eh.begincatch(i8* %exn, i8* null)
82 ; CHECK-NEXT: call void @llvm.eh.begincatch(i8* %exn, i8* null)
83 entry:
84 invoke void @_Z9may_throwv()
85 to label %try.cont unwind label %lpad
86
87 lpad: ; preds = %entry
88 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
89 catch i8* bitcast (i8** @_ZTIi to i8*)
90 %exn = extractvalue { i8*, i32 } %0, 0
91 %sel = extractvalue { i8*, i32 } %0, 1
92 %1 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
93 %matches = icmp eq i32 %sel, %1
94 br i1 %matches, label %catch, label %eh.resume
95
96 catch: ; preds = %lpad
97 call void @llvm.eh.begincatch(i8* %exn, i8* null)
98 call void @_Z10handle_intv()
99 br label %invoke.cont2
100
101 invoke.cont2: ; preds = %catch
102 call void @llvm.eh.begincatch(i8* %exn, i8* null)
103103 call void @llvm.eh.endcatch()
104104 br label %try.cont
105105
129129 br i1 %matches, label %catch, label %eh.resume
130130
131131 catch: ; preds = %lpad
132 %2 = call i8* @llvm.eh.begincatch(i8* %exn)
132 call void @llvm.eh.begincatch(i8* %exn, i8* null)
133133 call void @_Z10handle_intv()
134134 call void @llvm.eh.endcatch()
135135 br label %invoke.cont2
149149 ; Function Attrs: uwtable
150150 define void @test_begincatch_without_lpad() {
151151 ; CHECK: llvm.eh.begincatch may be reachable without passing a landingpad
152 ; CHECK-NEXT: %0 = call i8* @llvm.eh.begincatch(i8* %exn)
152 ; CHECK-NEXT: call void @llvm.eh.begincatch(i8* %exn, i8* null)
153153 entry:
154154 %exn = alloca i8
155 %0 = call i8* @llvm.eh.begincatch(i8* %exn)
155 call void @llvm.eh.begincatch(i8* %exn, i8* null)
156156 call void @_Z10handle_intv()
157157 br label %invoke.cont2
158158
167167 ; Function Attrs: uwtable
168168 define void @test_branch_to_begincatch_with_no_lpad(i32 %fake.sel) {
169169 ; CHECK: llvm.eh.begincatch may be reachable without passing a landingpad
170 ; CHECK-NEXT: %3 = call i8* @llvm.eh.begincatch(i8* %exn2)
170 ; CHECK-NEXT: call void @llvm.eh.begincatch(i8* %exn2, i8* null)
171171 entry:
172172 %fake.exn = alloca i8
173173 invoke void @_Z9may_throwv()
188188 catch: ; preds = %lpad, %entry
189189 %exn2 = phi i8* [%exn, %lpad], [%fake.exn, %entry]
190190 %sel2 = phi i32 [%sel, %lpad], [%fake.sel, %entry]
191 %3 = call i8* @llvm.eh.begincatch(i8* %exn2)
191 call void @llvm.eh.begincatch(i8* %exn2, i8* null)
192192 call void @_Z10handle_intv()
193193 %matches1 = icmp eq i32 %sel2, 0
194194 br i1 %matches1, label %invoke.cont2, label %invoke.cont3
212212 ; Function Attrs: uwtable
213213 define void @test_branch_missing_endcatch() {
214214 ; CHECK: Some paths from llvm.eh.begincatch may not reach llvm.eh.endcatch
215 ; CHECK-NEXT: %3 = call i8* @llvm.eh.begincatch(i8* %exn2)
215 ; CHECK-NEXT: call void @llvm.eh.begincatch(i8* %exn2, i8* null)
216216 entry:
217217 invoke void @_Z9may_throwv()
218218 to label %invoke.cont unwind label %lpad
246246 catch: ; preds = %lpad, %lpad1
247247 %exn2 = phi i8* [%exn, %lpad], [%exn1, %lpad1]
248248 %sel2 = phi i32 [%sel, %lpad], [%sel1, %lpad1]
249 %3 = call i8* @llvm.eh.begincatch(i8* %exn2)
249 call void @llvm.eh.begincatch(i8* %exn2, i8* null)
250250 call void @_Z10handle_intv()
251251 %matches1 = icmp eq i32 %sel2, 0
252252 br i1 %matches1, label %invoke.cont2, label %invoke.cont3
3939
4040 catch: ; preds = %lpad
4141 %exn = load i8*, i8** %exn.slot
42 %tmp3 = call i8* @llvm.eh.begincatch(i8* %exn) #2
42 call void @llvm.eh.begincatch(i8* %exn, i8* null) #2
4343 call void @_Z16handle_exceptionv()
4444 br label %invoke.cont2
4545
6565
6666 declare i32 @__CxxFrameHandler3(...)
6767
68 declare i8* @llvm.eh.begincatch(i8*)
68 declare void @llvm.eh.begincatch(i8*, i8*)
6969
7070 declare void @_Z16handle_exceptionv() #1
7171
6161
6262 catch: ; preds = %catch.dispatch
6363 %exn11 = load i8*, i8** %exn.slot
64 %tmp4 = call i8* @llvm.eh.begincatch(i8* %exn11) #3
65 %tmp5 = bitcast i8* %tmp4 to i32*
66 %tmp6 = load i32, i32* %tmp5, align 4
67 store i32 %tmp6, i32* %i, align 4
64 %i.i8 = bitcast i32* %i to i8*
65 call void @llvm.eh.begincatch(i8* %exn11, i8* %i.i8) #3
6866 %tmp7 = load i32, i32* %i, align 4
6967 call void @_Z10handle_inti(i32 %tmp7)
7068 br label %invoke.cont2
9189 ; CHECK: %eh.obj.ptr = getelementptr inbounds %struct._Z4testv.ehdata, %struct._Z4testv.ehdata* %eh.data, i32 0, i32 1
9290 ; CHECK: %eh.obj = load i8*, i8** %eh.obj.ptr
9391 ; CHECK: %i = getelementptr inbounds %struct._Z4testv.ehdata, %struct._Z4testv.ehdata* %eh.data, i32 0, i32 2
94 ; CHECK: %tmp5 = bitcast i8* %eh.obj to i32*
95 ; CHECK: %tmp6 = load i32, i32* %tmp5, align 4
96 ; CHECK: store i32 %tmp6, i32* %i, align 4
9792 ; CHECK: %tmp7 = load i32, i32* %i, align 4
9893 ; CHECK: call void @_Z10handle_inti(i32 %tmp7)
9994 ; CHECK: ret i8* blockaddress(@_Z4testv, %try.cont)
106101 ; Function Attrs: nounwind readnone
107102 declare i32 @llvm.eh.typeid.for(i8*) #2
108103
109 declare i8* @llvm.eh.begincatch(i8*)
104 declare void @llvm.eh.begincatch(i8*, i8*)
110105
111106 declare void @llvm.eh.endcatch()
112107
115115
116116 catch: ; preds = %catch.dispatch
117117 %exn = load i8*, i8** %exn.slot
118 %tmp8 = call i8* @llvm.eh.begincatch(i8* %exn) #1
119 %tmp9 = bitcast i8* %tmp8 to i32*
120 %tmp10 = load i32, i32* %tmp9, align 4
121 store i32 %tmp10, i32* %e, align 4
118 %e.i8 = bitcast i32* %e to i8*
119 call void @llvm.eh.begincatch(i8* %exn, i8* %e.i8) #1
122120 %tmp11 = load i32, i32* %e, align 4
123121 %tmp12 = load i32, i32* %NumExceptions, align 4
124122 %idxprom = sext i32 %tmp12 to i64
189187 ; CHECK: %ExceptionVal = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 4
190188 ; CHECK: %i = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 5
191189 ; CHECK: %Data = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 6
192 ; CHECK: %tmp9 = bitcast i8* %eh.obj to i32*
193 ; CHECK: %tmp10 = load i32, i32* %tmp9, align 4
194 ; CHECK: store i32 %tmp10, i32* %e, align 4
195190 ; CHECK: %tmp11 = load i32, i32* %e, align 4
196191 ; CHECK: %tmp12 = load i32, i32* %NumExceptions, align 4
197192 ; CHECK: %idxprom = sext i32 %tmp12 to i64
240235 ; Function Attrs: nounwind readnone
241236 declare i32 @llvm.eh.typeid.for(i8*) #3
242237
243 declare i8* @llvm.eh.begincatch(i8*)
238 declare void @llvm.eh.begincatch(i8*, i8*)
244239
245240 declare void @llvm.eh.endcatch()
246241
8383
8484 catch: ; preds = %catch.dispatch
8585 %exn = load i8*, i8** %exn.slot
86 %5 = call i8* @llvm.eh.begincatch(i8* %exn) #3
87 %6 = bitcast i8* %5 to i32*
88 %7 = load i32, i32* %6, align 4
89 store i32 %7, i32* %e, align 4
86 %e.i8 = bitcast i32* %e to i8*
87 call void @llvm.eh.begincatch(i8* %exn, i8* %e.i8) #3
9088 %a = getelementptr inbounds <{ %struct.A }>, <{ %struct.A }>* %0, i32 0, i32 0
9189 %a1 = getelementptr inbounds %struct.A, %struct.A* %a, i32 0, i32 0
92 %8 = load i32, i32* %a1, align 4
93 %9 = load i32, i32* %e, align 4
94 %add = add nsw i32 %8, %9
90 %tmp8 = load i32, i32* %a1, align 4
91 %tmp9 = load i32, i32* %e, align 4
92 %add = add nsw i32 %tmp8, %tmp9
9593 store i32 %add, i32* %retval
9694 store i32 1, i32* %cleanup.dest.slot
9795 call void @llvm.eh.endcatch() #3
108106 ; CHECK: %.tmp.reload1 = load volatile <{ %struct.A }>*, <{ %struct.A }>** %.tmp.reg2mem
109107 ; CHECK: %a2 = getelementptr inbounds <{ %struct.A }>, <{ %struct.A }>* %.tmp.reload1, i32 0, i32 0
110108 ; CHECK: call x86_thiscallcc void @"\01??1A@@QAE@XZ"(%struct.A* %a2) #2
111 ; CHECK: %10 = load i32, i32* %retval
112 ; CHECK: ret i32 %10
109 ; CHECK: %tmp10 = load i32, i32* %retval
110 ; CHECK: ret i32 %tmp10
113111
114112 cleanup: ; preds = %try.cont, %catch
115113 %a2 = getelementptr inbounds <{ %struct.A }>, <{ %struct.A }>* %0, i32 0, i32 0
116114 call x86_thiscallcc void @"\01??1A@@QAE@XZ"(%struct.A* %a2) #3
117 %10 = load i32, i32* %retval
118 ret i32 %10
115 %tmp10 = load i32, i32* %retval
116 ret i32 %tmp10
119117
120118 ehcleanup: ; preds = %catch.dispatch
121119 %a3 = getelementptr inbounds <{ %struct.A }>, <{ %struct.A }>* %0, i32 0, i32 0
142140 ; CHECK: %.reload = load <{ %struct.A }>*, <{ %struct.A }>** %eh.temp.alloca
143141 ; CHECK: %retval = getelementptr inbounds %"struct.\01?test@@YAHUA@@@Z.ehdata", %"struct.\01?test@@YAHUA@@@Z.ehdata"* %eh.data, i32 0, i32 4
144142 ; CHECK: %cleanup.dest.slot = getelementptr inbounds %"struct.\01?test@@YAHUA@@@Z.ehdata", %"struct.\01?test@@YAHUA@@@Z.ehdata"* %eh.data, i32 0, i32 5
145 ; CHECK: %2 = bitcast i8* %eh.obj to i32*
146 ; CHECK: %3 = load i32, i32* %2, align 4
147 ; CHECK: store i32 %3, i32* %e, align 4
148143 ; CHECK: %a = getelementptr inbounds <{ %struct.A }>, <{ %struct.A }>* %.reload, i32 0, i32 0
149144 ; CHECK: %a1 = getelementptr inbounds %struct.A, %struct.A* %a, i32 0, i32 0
150 ; CHECK: %4 = load i32, i32* %a1, align 4
151 ; CHECK: %5 = load i32, i32* %e, align 4
152 ; CHECK: %add = add nsw i32 %4, %5
145 ; CHECK: %tmp8 = load i32, i32* %a1, align 4
146 ; CHECK: %tmp9 = load i32, i32* %e, align 4
147 ; CHECK: %add = add nsw i32 %tmp8, %tmp9
153148 ; CHECK: store i32 %add, i32* %retval
154149 ; CHECK: store i32 1, i32* %cleanup.dest.slot
155150 ; CHECK: ret i8* blockaddress(@"\01?test@@YAHUA@@@Z", %cleanup)
163158 ; Function Attrs: nounwind readnone
164159 declare i32 @llvm.eh.typeid.for(i8*) #1
165160
166 declare i8* @llvm.eh.begincatch(i8*)
161 declare void @llvm.eh.begincatch(i8*, i8*)
167162
168163 declare void @llvm.eh.endcatch()
169164
5050 @"\01??_R0H@8" = linkonce_odr global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".H\00" }, comdat
5151
5252 ; This structure should be declared for the frame allocation block.
53 ; CHECK: %"struct.\01?test@@YAXXZ.ehdata" = type { i32, i8*, i32, [10 x i32], i32, i32*, i32* }
53 ; CHECK: %"struct.\01?test@@YAXXZ.ehdata" = type { i32, i8*, i32, i32, [10 x i32], i32, i32*, i32* }
5454
5555 ; The function entry should be rewritten like this.
5656 ; CHECK: define void @"\01?test@@YAXXZ"() #0 {
5757 ; CHECK: entry:
58 ; CHECK: %frame.alloc = call i8* @llvm.frameallocate(i32 80)
58 ; CHECK: %frame.alloc = call i8* @llvm.frameallocate(i32 88)
5959 ; CHECK: %eh.data = bitcast i8* %frame.alloc to %"struct.\01?test@@YAXXZ.ehdata"*
6060 ; CHECK-NOT: %ExceptionVal = alloca [10 x i32], align 16
61 ; CHECK: %NumExceptions.020.reg2mem = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 2
62 ; CHECK: %i.019.reg2mem = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 4
63 ; CHECK: %ExceptionVal = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 3
61 ; CHECK: %NumExceptions.020.reg2mem = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 3
62 ; CHECK: %i.019.reg2mem = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 5
63 ; CHECK: %ExceptionVal = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 4
6464 ; CHECK: %Data = alloca i64, align 8
6565 ; CHECK: %tmpcast = bitcast i64* %Data to %struct.SomeData*
6666 ; CHECK: %0 = bitcast [10 x i32]* %ExceptionVal to i8*
6767 ; CHECK: call void @llvm.lifetime.start(i64 40, i8* %0) #1
6868 ; CHECK: store i64 0, i64* %Data, align 8
69 ; CHECK: %a.reg2mem = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 5
69 ; CHECK: %a.reg2mem = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 6
7070 ; CHECK: %a = bitcast i64* %Data to i32*
7171 ; CHECK: store i32* %a, i32** %a.reg2mem
72 ; CHECK: %b.reg2mem = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 6
72 ; CHECK: %b.reg2mem = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 7
7373 ; CHECK: %b = getelementptr inbounds %struct.SomeData, %struct.SomeData* %tmpcast, i64 0, i32 1
7474 ; CHECK: store i32* %b, i32** %b.reg2mem
7575 ; CHECK: store i32 0, i32* %NumExceptions.020.reg2mem
7979 ; Function Attrs: uwtable
8080 define void @"\01?test@@YAXXZ"() #0 {
8181 entry:
82 %e = alloca i32, align 4
8283 %ExceptionVal = alloca [10 x i32], align 16
8384 %Data = alloca i64, align 8
8485 %tmpcast = bitcast i64* %Data to %struct.SomeData*
126127
127128 catch: ; preds = %lpad
128129 %5 = extractvalue { i8*, i32 } %2, 0
129 %6 = tail call i8* @llvm.eh.begincatch(i8* %5) #1
130 %7 = bitcast i8* %6 to i32*
131 %8 = load i32, i32* %7, align 4, !tbaa !7
130 %e.i8 = bitcast i32* %e to i8*
131 call void @llvm.eh.begincatch(i8* %5, i8* %e.i8) #1
132 %tmp8 = load i32, i32* %e, align 4, !tbaa !7
132133 %idxprom = sext i32 %NumExceptions.020 to i64
133134 %arrayidx = getelementptr inbounds [10 x i32], [10 x i32]* %ExceptionVal, i64 0, i64 %idxprom
134 store i32 %8, i32* %arrayidx, align 4, !tbaa !7
135 store i32 %tmp8, i32* %arrayidx, align 4, !tbaa !7
135136 %inc = add nsw i32 %NumExceptions.020, 1
136 %cmp1 = icmp eq i32 %8, %i.019
137 %cmp1 = icmp eq i32 %tmp8, %i.019
137138 br i1 %cmp1, label %if.then, label %if.else
138139
139140 if.then: ; preds = %catch
140 %9 = load i32, i32* %b, align 4, !tbaa !8
141 %add2 = add nsw i32 %9, %i.019
141 %tmp9 = load i32, i32* %b, align 4, !tbaa !8
142 %add2 = add nsw i32 %tmp9, %i.019
142143 store i32 %add2, i32* %b, align 4, !tbaa !8
143144 br label %if.end
144145
145146 if.else: ; preds = %catch
146 %10 = load i32, i32* %a, align 8, !tbaa !2
147 %add4 = add nsw i32 %10, %8
147 %tmp10 = load i32, i32* %a, align 8, !tbaa !2
148 %add4 = add nsw i32 %tmp10, %tmp8
148149 store i32 %add4, i32* %a, align 8, !tbaa !2
149150 br label %if.end
150151
189190 ; CHECK: %eh.data = bitcast i8* %eh.alloc to %"struct.\01?test@@YAXXZ.ehdata"*
190191 ; CHECK: %eh.obj.ptr = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 1
191192 ; CHECK: %eh.obj = load i8*, i8** %eh.obj.ptr
192 ; CHECK: %eh.temp.alloca = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 2
193 ; CHECK: %e = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 2
194 ; CHECK: %eh.temp.alloca = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 3
193195 ; CHECK: %NumExceptions.020.reload = load i32, i32* %eh.temp.alloca
194 ; CHECK: %ExceptionVal = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 3
195 ; CHECK: %eh.temp.alloca1 = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 4
196 ; CHECK: %ExceptionVal = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 4
197 ; CHECK: %eh.temp.alloca1 = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 5
196198 ; CHECK: %i.019.reload = load i32, i32* %eh.temp.alloca1
197 ; CHECK: %eh.temp.alloca2 = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 5
199 ; CHECK: %eh.temp.alloca2 = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 6
198200 ; CHECK: %a.reload = load i32*, i32** %eh.temp.alloca2
199 ; CHECK: %eh.temp.alloca3 = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 6
201 ; CHECK: %eh.temp.alloca3 = getelementptr inbounds %"struct.\01?test@@YAXXZ.ehdata", %"struct.\01?test@@YAXXZ.ehdata"* %eh.data, i32 0, i32 7
200202 ; CHECK: %b.reload = load i32*, i32** %eh.temp.alloca3
201 ; CHECK: %2 = bitcast i8* %eh.obj to i32*
202 ; CHECK: %3 = load i32, i32* %2, align 4, !tbaa !7
203 ; CHECK: %e.i8 = bitcast i32* %e to i8*
204 ; CHECK: %tmp8 = load i32, i32* %e, align 4, !tbaa !7
203205 ; CHECK: %idxprom = sext i32 %NumExceptions.020.reload to i64
204206 ; CHECK: %arrayidx = getelementptr inbounds [10 x i32], [10 x i32]* %ExceptionVal, i64 0, i64 %idxprom
205 ; CHECK: store i32 %3, i32* %arrayidx, align 4, !tbaa !7
207 ; CHECK: store i32 %tmp8, i32* %arrayidx, align 4, !tbaa !7
206208 ; CHECK: %inc = add nsw i32 %NumExceptions.020.reload, 1
207 ; CHECK: %cmp1 = icmp eq i32 %3, %i.019.reload
209 ; CHECK: %cmp1 = icmp eq i32 %tmp8, %i.019.reload
208210 ; CHECK: br i1 %cmp1, label %if.then, label %if.else
209211 ;
210212 ; CHECK: if.then: ; preds = %catch.entry
211 ; CHECK: %4 = load i32, i32* %b.reload, align 4, !tbaa !8
212 ; CHECK: %add2 = add nsw i32 %4, %i.019.reload
213 ; CHECK: %tmp9 = load i32, i32* %b.reload, align 4, !tbaa !8
214 ; CHECK: %add2 = add nsw i32 %tmp9, %i.019.reload
213215 ; CHECK: store i32 %add2, i32* %b.reload, align 4, !tbaa !8
214216 ; CHECK: br label %if.end
215217 ;
216218 ; CHECK: if.else: ; preds = %catch.entry
217 ; CHECK: %5 = load i32, i32* %a.reload, align 8, !tbaa !2
218 ; CHECK: %add4 = add nsw i32 %5, %3
219 ; CHECK: %tmp10 = load i32, i32* %a.reload, align 8, !tbaa !2
220 ; CHECK: %add4 = add nsw i32 %tmp10, %tmp8
219221 ; CHECK: store i32 %add4, i32* %a.reload, align 8, !tbaa !2
220222 ; CHECK: br label %if.end
221223 ;
233235 ; Function Attrs: nounwind readnone
234236 declare i32 @llvm.eh.typeid.for(i8*) #3
235237
236 declare i8* @llvm.eh.begincatch(i8*)
238 declare void @llvm.eh.begincatch(i8*, i8*)
237239
238240 declare void @llvm.eh.endcatch()
239241