1; RUN: llc -verify-machineinstrs < %s | FileCheck %s 2 3; CHECK-LABEL: "$cppxdata$?crash@@YAXH@Z": 4; CHECK: .long ("$stateUnwindMap$?crash@@YAXH@Z") 5; CHECK: .long ("$ip2state$?crash@@YAXH@Z") 6 7; CHECK-LABEL: "$stateUnwindMap$?crash@@YAXH@Z": 8; CHECK: .long -1 9; CHECK: .long "?dtor$ 10; CHECK: .long 0 11; CHECK: .long "?dtor$ 12; CHECK: .long 1 13; CHECK: .long "?dtor$ 14 15; CHECK-LABEL: "$ip2state$?crash@@YAXH@Z": 16; CHECK-NEXT: .long .Lfunc_begin0@IMGREL 17; CHECK-NEXT: .long -1 18; CHECK-NEXT: .long .Ltmp 19; CHECK-NEXT: .long 0 20; CHECK-NEXT: .long .Ltmp 21; CHECK-NEXT: .long 1 22; CHECK-NEXT: .long .Ltmp 23; CHECK-NEXT: .long 2 24; CHECK-NEXT: .long .Ltmp 25; CHECK-NEXT: .long 1 26; CHECK-NEXT: .long .Ltmp 27; CHECK-NEXT: .long 0 28; CHECK-NEXT: .long .Ltmp 29; CHECK-NEXT: .long -1 30 31; ModuleID = 'windows-seh-EHa-CppDtors01.cpp' 32source_filename = "windows-seh-EHa-CppDtors01.cpp" 33target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 34target triple = "x86_64-unknown-windows-msvc" 35 36%struct.A = type { i8 } 37%struct.B = type { i8 } 38%struct.C = type { i8 } 39 40$"??_C@_0CM@KAOHJHDK@?5Test?5CPP?5unwind?3?5in?5catch?5handl@" = comdat any 41 42$"??_C@_0N@FCCEEGKL@?5in?5C?5dtor?5?6?$AA@" = comdat any 43 44$"??_C@_0N@EFFPFCOI@?5in?5B?5dtor?5?6?$AA@" = comdat any 45 46$"??_C@_0N@HMNCGOCN@?5in?5A?5dtor?5?6?$AA@" = comdat any 47 48@"?g@@3HA" = dso_local global i32 0, align 4 49@"??_C@_0CM@KAOHJHDK@?5Test?5CPP?5unwind?3?5in?5catch?5handl@" = linkonce_odr dso_local unnamed_addr constant [44 x i8] c" Test CPP unwind: in catch handler i = %d \0A\00", comdat, align 1 50@"??_C@_0N@FCCEEGKL@?5in?5C?5dtor?5?6?$AA@" = linkonce_odr dso_local unnamed_addr constant [13 x i8] c" in C dtor \0A\00", comdat, align 1 51@"??_C@_0N@EFFPFCOI@?5in?5B?5dtor?5?6?$AA@" = linkonce_odr dso_local unnamed_addr constant [13 x i8] c" in B dtor \0A\00", comdat, align 1 52@"??_C@_0N@HMNCGOCN@?5in?5A?5dtor?5?6?$AA@" = linkonce_odr dso_local unnamed_addr constant [13 x i8] c" in A dtor \0A\00", comdat, align 1 53 54; Function Attrs: noinline optnone 55define dso_local void @"?crash@@YAXH@Z"(i32 %i) #0 personality ptr @__CxxFrameHandler3 { 56entry: 57 %i.addr = alloca i32, align 4 58 %ObjA = alloca %struct.A, align 1 59 %ObjB = alloca %struct.B, align 1 60 %ObjC = alloca %struct.C, align 1 61 store i32 %i, ptr %i.addr, align 4 62 invoke void @llvm.seh.scope.begin() 63 to label %invoke.cont unwind label %ehcleanup13 64 65invoke.cont: ; preds = %entry 66 %0 = load i32, ptr %i.addr, align 4 67 %cmp = icmp eq i32 %0, 0 68 br i1 %cmp, label %if.then, label %if.end 69 70if.then: ; preds = %invoke.cont 71 store volatile i32 0, ptr inttoptr (i64 17 to ptr), align 4 72 br label %if.end 73 74if.end: ; preds = %if.then, %invoke.cont 75 invoke void @llvm.seh.scope.begin() 76 to label %invoke.cont1 unwind label %ehcleanup11 77 78invoke.cont1: ; preds = %if.end 79 %1 = load i32, ptr %i.addr, align 4 80 %cmp2 = icmp eq i32 %1, 1 81 br i1 %cmp2, label %if.then3, label %if.end4 82 83if.then3: ; preds = %invoke.cont1 84 store volatile i32 0, ptr inttoptr (i64 17 to ptr), align 4 85 br label %if.end4 86 87if.end4: ; preds = %if.then3, %invoke.cont1 88 invoke void @llvm.seh.scope.begin() 89 to label %invoke.cont5 unwind label %ehcleanup 90 91invoke.cont5: ; preds = %if.end4 92 %2 = load i32, ptr %i.addr, align 4 93 %cmp6 = icmp eq i32 %2, 2 94 br i1 %cmp6, label %if.then7, label %if.end8 95 96if.then7: ; preds = %invoke.cont5 97 store volatile i32 0, ptr inttoptr (i64 17 to ptr), align 4 98 br label %if.end8 99 100if.end8: ; preds = %if.then7, %invoke.cont5 101 invoke void @llvm.seh.scope.end() 102 to label %invoke.cont9 unwind label %ehcleanup 103 104invoke.cont9: ; preds = %if.end8 105 call void @"??1C@?1??crash@@YAXH@Z@QEAA@XZ"(ptr %ObjC) #6 106 invoke void @llvm.seh.scope.end() 107 to label %invoke.cont10 unwind label %ehcleanup11 108 109invoke.cont10: ; preds = %invoke.cont9 110 call void @"??1B@?1??crash@@YAXH@Z@QEAA@XZ"(ptr %ObjB) #6 111 invoke void @llvm.seh.scope.end() 112 to label %invoke.cont12 unwind label %ehcleanup13 113 114invoke.cont12: ; preds = %invoke.cont10 115 call void @"??1A@?1??crash@@YAXH@Z@QEAA@XZ"(ptr %ObjA) #6 116 ret void 117 118ehcleanup: ; preds = %if.end8, %if.end4 119 %3 = cleanuppad within none [] 120 call void @"??1C@?1??crash@@YAXH@Z@QEAA@XZ"(ptr %ObjC) #6 [ "funclet"(token %3) ] 121 cleanupret from %3 unwind label %ehcleanup11 122 123ehcleanup11: ; preds = %invoke.cont9, %ehcleanup, %if.end 124 %4 = cleanuppad within none [] 125 call void @"??1B@?1??crash@@YAXH@Z@QEAA@XZ"(ptr %ObjB) #6 [ "funclet"(token %4) ] 126 cleanupret from %4 unwind label %ehcleanup13 127 128ehcleanup13: ; preds = %invoke.cont10, %ehcleanup11, %entry 129 %5 = cleanuppad within none [] 130 call void @"??1A@?1??crash@@YAXH@Z@QEAA@XZ"(ptr %ObjA) #6 [ "funclet"(token %5) ] 131 cleanupret from %5 unwind to caller 132} 133 134; Function Attrs: nounwind readnone 135declare dso_local void @llvm.seh.scope.begin() #1 136 137declare dso_local i32 @__CxxFrameHandler3(...) 138 139; Function Attrs: nounwind readnone 140declare dso_local void @llvm.seh.scope.end() #1 141 142; Function Attrs: noinline nounwind optnone 143define internal void @"??1C@?1??crash@@YAXH@Z@QEAA@XZ"(ptr %this) unnamed_addr #2 align 2 { 144entry: 145 %this.addr = alloca ptr, align 8 146 store ptr %this, ptr %this.addr, align 8 147 %this1 = load ptr, ptr %this.addr, align 8 148 call void (...) @"?printf@@YAXZZ"(ptr @"??_C@_0N@FCCEEGKL@?5in?5C?5dtor?5?6?$AA@") 149 ret void 150} 151 152; Function Attrs: noinline nounwind optnone 153define internal void @"??1B@?1??crash@@YAXH@Z@QEAA@XZ"(ptr %this) unnamed_addr #2 align 2 { 154entry: 155 %this.addr = alloca ptr, align 8 156 store ptr %this, ptr %this.addr, align 8 157 %this1 = load ptr, ptr %this.addr, align 8 158 call void (...) @"?printf@@YAXZZ"(ptr @"??_C@_0N@EFFPFCOI@?5in?5B?5dtor?5?6?$AA@") 159 ret void 160} 161 162; Function Attrs: noinline nounwind optnone 163define internal void @"??1A@?1??crash@@YAXH@Z@QEAA@XZ"(ptr %this) unnamed_addr #2 align 2 { 164entry: 165 %this.addr = alloca ptr, align 8 166 store ptr %this, ptr %this.addr, align 8 167 %this1 = load ptr, ptr %this.addr, align 8 168 call void (...) @"?printf@@YAXZZ"(ptr @"??_C@_0N@HMNCGOCN@?5in?5A?5dtor?5?6?$AA@") 169 ret void 170} 171 172; Function Attrs: noinline norecurse optnone 173define dso_local i32 @main() #3 personality ptr @__C_specific_handler { 174entry: 175 %retval = alloca i32, align 4 176 %i = alloca i32, align 4 177 %__exception_code = alloca i32, align 4 178 store i32 0, ptr %retval, align 4 179 store i32 0, ptr %i, align 4 180 br label %for.cond 181 182for.cond: ; preds = %for.inc, %entry 183 %0 = load i32, ptr %i, align 4 184 %cmp = icmp slt i32 %0, 3 185 br i1 %cmp, label %for.body, label %for.end 186 187for.body: ; preds = %for.cond 188 invoke void @llvm.seh.try.begin() 189 to label %invoke.cont unwind label %catch.dispatch 190 191invoke.cont: ; preds = %for.body 192 %1 = load volatile i32, ptr %i, align 4 193 invoke void @"?crash@@YAXH@Z"(i32 %1) #7 194 to label %invoke.cont1 unwind label %catch.dispatch 195 196invoke.cont1: ; preds = %invoke.cont 197 invoke void @llvm.seh.try.end() 198 to label %invoke.cont2 unwind label %catch.dispatch 199 200catch.dispatch: ; preds = %invoke.cont1, %invoke.cont, %for.body 201 %2 = catchswitch within none [label %__except] unwind to caller 202 203__except: ; preds = %catch.dispatch 204 %3 = catchpad within %2 [ptr null] 205 catchret from %3 to label %__except3 206 207__except3: ; preds = %__except 208 %4 = call i32 @llvm.eh.exceptioncode(token %3) 209 store i32 %4, ptr %__exception_code, align 4 210 %5 = load i32, ptr %i, align 4 211 call void (...) @"?printf@@YAXZZ"(ptr @"??_C@_0CM@KAOHJHDK@?5Test?5CPP?5unwind?3?5in?5catch?5handl@", i32 %5) 212 br label %__try.cont 213 214__try.cont: ; preds = %__except3, %invoke.cont2 215 br label %for.inc 216 217for.inc: ; preds = %__try.cont 218 %6 = load i32, ptr %i, align 4 219 %inc = add nsw i32 %6, 1 220 store i32 %inc, ptr %i, align 4 221 br label %for.cond 222 223invoke.cont2: ; preds = %invoke.cont1 224 br label %__try.cont 225 226for.end: ; preds = %for.cond 227 ret i32 0 228} 229 230; Function Attrs: nounwind willreturn 231declare dso_local void @llvm.seh.try.begin() #4 232 233declare dso_local i32 @__C_specific_handler(...) 234 235; Function Attrs: nounwind willreturn 236declare dso_local void @llvm.seh.try.end() #4 237 238; Function Attrs: nounwind readnone 239declare i32 @llvm.eh.exceptioncode(token) #1 240 241declare dso_local void @"?printf@@YAXZZ"(...) #5 242 243attributes #0 = { noinline optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } 244attributes #1 = { nounwind readnone } 245attributes #2 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } 246attributes #3 = { noinline norecurse optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } 247attributes #4 = { nounwind willreturn } 248attributes #5 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } 249attributes #6 = { nounwind } 250attributes #7 = { noinline } 251 252!llvm.module.flags = !{!0, !1} 253 254!0 = !{i32 1, !"wchar_size", i32 2} 255!1 = !{i32 2, !"eh-asynch", i32 1} 256