Andrew Kaylor | 3170e56 | 2015-03-20 21:42:54 +0000 | [diff] [blame] | 1 | ; RUN: opt -mtriple=x86_64-pc-windows-msvc -winehprepare -S -o - < %s | FileCheck %s |
| 2 | |
| 3 | ; This test was generated from the following source: |
| 4 | ; |
| 5 | ; void test() { |
| 6 | ; try { |
| 7 | ; SomeClass obj; |
| 8 | ; may_throw(); |
| 9 | ; try { |
| 10 | ; may_throw(); |
| 11 | ; } catch (int) { |
| 12 | ; handle_exception(); |
| 13 | ; } |
| 14 | ; } catch (int) { |
| 15 | ; handle_exception(); |
| 16 | ; } |
| 17 | ; } |
| 18 | ; |
| 19 | ; The code above was compiled with the -O2 option. |
| 20 | |
| 21 | ; ModuleID = 'catch-unwind.cpp' |
| 22 | target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" |
| 23 | target triple = "x86_64-pc-windows-msvc" |
| 24 | |
| 25 | %rtti.TypeDescriptor2 = type { i8**, i8*, [3 x i8] } |
| 26 | %class.SomeClass = type { i8 } |
| 27 | |
| 28 | $"\01??_R0H@8" = comdat any |
| 29 | |
| 30 | @"\01??_7type_info@@6B@" = external constant i8* |
| 31 | @"\01??_R0H@8" = linkonce_odr global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".H\00" }, comdat |
| 32 | |
| 33 | |
| 34 | ; CHECK-LABEL: define void @"\01?test@@YAXXZ"() #0 { |
| 35 | ; CHECK: entry: |
| 36 | ; CHECK: [[OBJ_PTR:\%.+]] = alloca %class.SomeClass |
| 37 | ; CHECK: [[TMP0:\%.+]] = alloca i32, align 4 |
| 38 | ; CHECK: [[TMP1:\%.+]] = alloca i32, align 4 |
David Blaikie | 23af648 | 2015-04-16 23:24:18 +0000 | [diff] [blame] | 39 | ; CHECK: call void (...) @llvm.frameescape(i32* [[TMP1]], %class.SomeClass* [[OBJ_PTR]], i32* [[TMP0]]) |
Andrew Kaylor | 3170e56 | 2015-03-20 21:42:54 +0000 | [diff] [blame] | 40 | ; CHECK: %call = invoke %class.SomeClass* @"\01??0SomeClass@@QEAA@XZ"(%class.SomeClass* %obj) |
| 41 | ; CHECK: to label %invoke.cont unwind label %[[LPAD_LABEL:lpad[0-9]+]] |
| 42 | |
| 43 | ; Function Attrs: uwtable |
| 44 | define void @"\01?test@@YAXXZ"() #0 { |
| 45 | entry: |
| 46 | %obj = alloca %class.SomeClass, align 1 |
| 47 | %0 = alloca i32, align 4 |
| 48 | %1 = alloca i32, align 4 |
| 49 | %call = invoke %class.SomeClass* @"\01??0SomeClass@@QEAA@XZ"(%class.SomeClass* %obj) |
| 50 | to label %invoke.cont unwind label %lpad |
| 51 | |
| 52 | ; CHECK: invoke.cont: |
| 53 | ; CHECK: invoke void @"\01?may_throw@@YAXXZ"() |
| 54 | ; CHECK: to label %invoke.cont2 unwind label %[[LPAD1_LABEL:lpad[0-9]+]] |
| 55 | |
| 56 | invoke.cont: ; preds = %entry |
| 57 | invoke void @"\01?may_throw@@YAXXZ"() |
| 58 | to label %invoke.cont2 unwind label %lpad1 |
| 59 | |
| 60 | ; CHECK: invoke.cont2: |
| 61 | ; CHECK: invoke void @"\01?may_throw@@YAXXZ"() |
| 62 | ; CHECK: to label %try.cont unwind label %[[LPAD3_LABEL:lpad[0-9]+]] |
| 63 | |
| 64 | invoke.cont2: ; preds = %invoke.cont |
| 65 | invoke void @"\01?may_throw@@YAXXZ"() |
| 66 | to label %try.cont unwind label %lpad3 |
| 67 | |
| 68 | ; CHECK: [[LPAD_LABEL]]:{{[ ]+}}; preds = %entry |
| 69 | ; CHECK: [[LPAD_VAL:\%.+]] = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) |
| 70 | ; CHECK-NEXT: catch i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*) |
David Blaikie | 23af648 | 2015-04-16 23:24:18 +0000 | [diff] [blame] | 71 | ; CHECK-NEXT: [[RECOVER:\%.+]] = call i8* (...) @llvm.eh.actions(i32 1, i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*), i32 0, i8* (i8*, i8*)* @"\01?test@@YAXXZ.catch") |
Andrew Kaylor | 3170e56 | 2015-03-20 21:42:54 +0000 | [diff] [blame] | 72 | ; CHECK-NEXT: indirectbr i8* [[RECOVER]], [label %try.cont15] |
| 73 | |
| 74 | lpad: ; preds = %entry |
| 75 | %2 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) |
| 76 | catch i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*) |
| 77 | %3 = extractvalue { i8*, i32 } %2, 0 |
| 78 | %4 = extractvalue { i8*, i32 } %2, 1 |
| 79 | br label %catch.dispatch7 |
| 80 | |
| 81 | ; CHECK: [[LPAD1_LABEL]]:{{[ ]+}}; preds = %invoke.cont |
| 82 | ; CHECK: [[LPAD1_VAL:\%.+]] = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) |
| 83 | ; CHECK-NEXT: cleanup |
| 84 | ; CHECK-NEXT: catch i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*) |
David Blaikie | 23af648 | 2015-04-16 23:24:18 +0000 | [diff] [blame] | 85 | ; CHECK-NEXT: [[RECOVER1:\%.+]] = call i8* (...) @llvm.eh.actions(i32 0, void (i8*, i8*)* @"\01?test@@YAXXZ.cleanup", i32 1, i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*), i32 0, i8* (i8*, i8*)* @"\01?test@@YAXXZ.catch") |
Andrew Kaylor | 3170e56 | 2015-03-20 21:42:54 +0000 | [diff] [blame] | 86 | ; CHECK-NEXT: indirectbr i8* [[RECOVER1]], [label %try.cont15] |
| 87 | |
| 88 | lpad1: ; preds = %invoke.cont |
| 89 | %5 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) |
| 90 | cleanup |
| 91 | catch i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*) |
| 92 | %6 = extractvalue { i8*, i32 } %5, 0 |
| 93 | %7 = extractvalue { i8*, i32 } %5, 1 |
| 94 | br label %ehcleanup |
| 95 | |
| 96 | ; CHECK: [[LPAD3_LABEL]]:{{[ ]+}}; preds = %invoke.cont2 |
| 97 | ; CHECK: [[LPAD3_VAL:\%.+]] = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) |
| 98 | ; CHECK-NEXT: cleanup |
| 99 | ; CHECK-NEXT: catch i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*) |
David Blaikie | 23af648 | 2015-04-16 23:24:18 +0000 | [diff] [blame] | 100 | ; CHECK-NEXT: [[RECOVER3:\%.+]] = call i8* (...) @llvm.eh.actions(i32 1, i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*), i32 2, i8* (i8*, i8*)* @"\01?test@@YAXXZ.catch1", i32 0, void (i8*, i8*)* @"\01?test@@YAXXZ.cleanup") |
Andrew Kaylor | 3170e56 | 2015-03-20 21:42:54 +0000 | [diff] [blame] | 101 | ; CHECK-NEXT: indirectbr i8* [[RECOVER3]], [label %try.cont] |
| 102 | |
| 103 | lpad3: ; preds = %invoke.cont2 |
| 104 | %8 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) |
| 105 | cleanup |
| 106 | catch i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*) |
| 107 | %9 = extractvalue { i8*, i32 } %8, 0 |
| 108 | %10 = extractvalue { i8*, i32 } %8, 1 |
| 109 | %11 = call i32 @llvm.eh.typeid.for(i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*)) #3 |
| 110 | %matches = icmp eq i32 %10, %11 |
| 111 | br i1 %matches, label %catch, label %ehcleanup |
| 112 | |
| 113 | ; CHECK-NOT: catch: |
| 114 | catch: ; preds = %lpad3 |
| 115 | %12 = bitcast i32* %0 to i8* |
| 116 | call void @llvm.eh.begincatch(i8* %9, i8* %12) #3 |
| 117 | invoke void @"\01?handle_exception@@YAXXZ"() |
| 118 | to label %invoke.cont6 unwind label %lpad5 |
| 119 | |
| 120 | ; CHECK-NOT: invoke.cont6: |
| 121 | invoke.cont6: ; preds = %catch |
| 122 | call void @llvm.eh.endcatch() #3 |
| 123 | br label %try.cont |
| 124 | |
| 125 | try.cont: ; preds = %invoke.cont2, %invoke.cont6 |
| 126 | call void @"\01??1SomeClass@@QEAA@XZ"(%class.SomeClass* %obj) #3 |
| 127 | br label %try.cont15 |
| 128 | |
| 129 | ; CHECK-NOT: lpad5: |
| 130 | lpad5: ; preds = %catch |
| 131 | %13 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) |
| 132 | cleanup |
| 133 | catch i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*) |
| 134 | %14 = extractvalue { i8*, i32 } %13, 0 |
| 135 | %15 = extractvalue { i8*, i32 } %13, 1 |
| 136 | call void @llvm.eh.endcatch() #3 |
| 137 | br label %ehcleanup |
| 138 | |
| 139 | ; CHECK-NOT: ehcleanup |
| 140 | ehcleanup: ; preds = %lpad5, %lpad3, %lpad1 |
| 141 | %exn.slot.0 = phi i8* [ %14, %lpad5 ], [ %9, %lpad3 ], [ %6, %lpad1 ] |
| 142 | %ehselector.slot.0 = phi i32 [ %15, %lpad5 ], [ %10, %lpad3 ], [ %7, %lpad1 ] |
| 143 | call void @"\01??1SomeClass@@QEAA@XZ"(%class.SomeClass* %obj) #3 |
| 144 | br label %catch.dispatch7 |
| 145 | |
| 146 | ; CHECK-NOT: catch.dispatch7: |
| 147 | catch.dispatch7: ; preds = %ehcleanup, %lpad |
| 148 | %exn.slot.1 = phi i8* [ %exn.slot.0, %ehcleanup ], [ %3, %lpad ] |
| 149 | %ehselector.slot.1 = phi i32 [ %ehselector.slot.0, %ehcleanup ], [ %4, %lpad ] |
| 150 | %16 = call i32 @llvm.eh.typeid.for(i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*)) #3 |
| 151 | %matches9 = icmp eq i32 %ehselector.slot.1, %16 |
| 152 | br i1 %matches9, label %catch10, label %eh.resume |
| 153 | |
| 154 | ; CHECK-NOT: catch10: |
| 155 | catch10: ; preds = %catch.dispatch7 |
| 156 | %17 = bitcast i32* %1 to i8* |
| 157 | call void @llvm.eh.begincatch(i8* %exn.slot.1, i8* %17) #3 |
| 158 | call void @"\01?handle_exception@@YAXXZ"() |
| 159 | br label %invoke.cont13 |
| 160 | |
| 161 | ; CHECK-NOT: invoke.cont13: |
| 162 | invoke.cont13: ; preds = %catch10 |
| 163 | call void @llvm.eh.endcatch() #3 |
| 164 | br label %try.cont15 |
| 165 | |
| 166 | try.cont15: ; preds = %invoke.cont13, %try.cont |
| 167 | ret void |
| 168 | |
| 169 | ; CHECK-NOT: eh.resume |
| 170 | eh.resume: ; preds = %catch.dispatch7 |
| 171 | %lpad.val = insertvalue { i8*, i32 } undef, i8* %exn.slot.1, 0 |
| 172 | %lpad.val18 = insertvalue { i8*, i32 } %lpad.val, i32 %ehselector.slot.1, 1 |
| 173 | resume { i8*, i32 } %lpad.val18 |
| 174 | |
| 175 | ; CHECK: } |
| 176 | } |
| 177 | |
David Majnemer | cde3303 | 2015-03-30 22:58:10 +0000 | [diff] [blame] | 178 | ; CHECK-LABEL: define internal i8* @"\01?test@@YAXXZ.catch"(i8*, i8*) |
Andrew Kaylor | 3170e56 | 2015-03-20 21:42:54 +0000 | [diff] [blame] | 179 | ; CHECK: entry: |
| 180 | ; CHECK: [[RECOVER_TMP1:\%.+]] = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 0) |
| 181 | ; CHECK: [[TMP1_PTR:\%.+]] = bitcast i8* [[RECOVER_TMP1]] to i32* |
| 182 | ; CHECK: call void @"\01?handle_exception@@YAXXZ"() |
| 183 | ; CHECK: ret i8* blockaddress(@"\01?test@@YAXXZ", %try.cont15) |
| 184 | ; CHECK: } |
| 185 | |
David Majnemer | cde3303 | 2015-03-30 22:58:10 +0000 | [diff] [blame] | 186 | ; CHECK-LABEL: define internal void @"\01?test@@YAXXZ.cleanup"(i8*, i8*) |
Andrew Kaylor | 3170e56 | 2015-03-20 21:42:54 +0000 | [diff] [blame] | 187 | ; CHECK: entry: |
| 188 | ; CHECK: [[RECOVER_OBJ:\%.+]] = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 1) |
| 189 | ; CHECK: [[OBJ_PTR:\%.+]] = bitcast i8* %obj.i8 to %class.SomeClass* |
David Majnemer | cde3303 | 2015-03-30 22:58:10 +0000 | [diff] [blame] | 190 | ; CHECK: call void @"\01??1SomeClass@@QEAA@XZ"(%class.SomeClass* [[OBJ_PTR]]) |
Andrew Kaylor | 3170e56 | 2015-03-20 21:42:54 +0000 | [diff] [blame] | 191 | ; CHECK: ret void |
| 192 | ; CHECK: } |
| 193 | |
David Majnemer | cde3303 | 2015-03-30 22:58:10 +0000 | [diff] [blame] | 194 | ; CHECK-LABEL: define internal i8* @"\01?test@@YAXXZ.catch1"(i8*, i8*) |
Andrew Kaylor | 3170e56 | 2015-03-20 21:42:54 +0000 | [diff] [blame] | 195 | ; CHECK: entry: |
Andrew Kaylor | 3170e56 | 2015-03-20 21:42:54 +0000 | [diff] [blame] | 196 | ; CHECK: [[RECOVER_TMP0:\%.+]] = call i8* @llvm.framerecover(i8* bitcast (void ()* @"\01?test@@YAXXZ" to i8*), i8* %1, i32 2) |
| 197 | ; CHECK: [[TMP0_PTR:\%.+]] = bitcast i8* [[RECOVER_TMP0]] to i32* |
| 198 | ; CHECK: invoke void @"\01?handle_exception@@YAXXZ"() |
| 199 | ; CHECK: to label %invoke.cont6 unwind label %[[LPAD5_LABEL:lpad[0-9]+]] |
| 200 | ; |
| 201 | ; CHECK: invoke.cont6: ; preds = %entry |
| 202 | ; CHECK: ret i8* blockaddress(@"\01?test@@YAXXZ", %try.cont) |
| 203 | ; |
| 204 | ; CHECK: [[LPAD5_LABEL]]:{{[ ]+}}; preds = %entry |
| 205 | ; CHECK: [[LPAD5_VAL:\%.+]] = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) |
| 206 | ; CHECK: cleanup |
| 207 | ; CHECK: catch i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*) |
Andrew Kaylor | 3170e56 | 2015-03-20 21:42:54 +0000 | [diff] [blame] | 208 | ; CHECK: } |
| 209 | |
| 210 | declare %class.SomeClass* @"\01??0SomeClass@@QEAA@XZ"(%class.SomeClass* returned) #1 |
| 211 | |
| 212 | declare i32 @__CxxFrameHandler3(...) |
| 213 | |
| 214 | declare void @"\01?may_throw@@YAXXZ"() #1 |
| 215 | |
| 216 | ; Function Attrs: nounwind readnone |
| 217 | declare i32 @llvm.eh.typeid.for(i8*) #2 |
| 218 | |
| 219 | ; Function Attrs: nounwind |
| 220 | declare void @llvm.eh.begincatch(i8* nocapture, i8* nocapture) #3 |
| 221 | |
| 222 | declare void @"\01?handle_exception@@YAXXZ"() #1 |
| 223 | |
| 224 | ; Function Attrs: nounwind |
| 225 | declare void @llvm.eh.endcatch() #3 |
| 226 | |
| 227 | ; Function Attrs: nounwind |
| 228 | declare void @"\01??1SomeClass@@QEAA@XZ"(%class.SomeClass*) #4 |
| 229 | |
| 230 | attributes #0 = { uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 231 | attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 232 | attributes #2 = { nounwind readnone } |
| 233 | attributes #3 = { nounwind } |
| 234 | attributes #4 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 235 | |
| 236 | !llvm.module.flags = !{!0} |
| 237 | !llvm.ident = !{!1} |
| 238 | |
| 239 | !0 = !{i32 1, !"PIC Level", i32 2} |
| 240 | !1 = !{!"clang version 3.7.0 (trunk 232069) (llvm/trunk 232070)"} |