227 lines · plain
1; RUN: llc < %s | FileCheck %s2 3target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"4target triple = "i686-pc-windows-msvc"5 6define void @try_except() #0 personality ptr @_except_handler3 {7entry:8 %__exception_code = alloca i32, align 49 call void (...) @llvm.localescape(ptr %__exception_code)10 invoke void @f(i32 1) #311 to label %invoke.cont unwind label %catch.dispatch12 13catch.dispatch: ; preds = %entry14 %cs1 = catchswitch within none [label %__except.ret] unwind to caller15 16__except.ret: ; preds = %catch.dispatch17 %0 = catchpad within %cs1 [ptr @try_except_filter_catchall]18 catchret from %0 to label %__except19 20__except: ; preds = %__except.ret21 call void @f(i32 2)22 br label %__try.cont23 24__try.cont: ; preds = %__except, %invoke.cont25 call void @f(i32 3)26 ret void27 28invoke.cont: ; preds = %entry29 br label %__try.cont30}31 32; CHECK-LABEL: _try_except:33; Store state #034; CHECK: movl $0, -[[state:[0-9]+]](%ebp)35; CHECK: pushl $136; CHECK: calll _f37; CHECK: movl $-1, -[[state]](%ebp)38; CHECK: pushl $339; CHECK: calll _f40; CHECK: retl41 42; __except43; CHECK: movl $-1, -[[state]](%ebp)44; CHECK: pushl $245; CHECK: calll _f46 47; CHECK: .section .xdata,"dr"48; CHECK: L__ehtable$try_except:49; CHECK: .long -1 # ToState50; CHECK: .long _try_except_filter_catchall # Filter51; CHECK: .long LBB0_152 53define internal i32 @try_except_filter_catchall() #0 {54entry:55 %0 = call ptr @llvm.frameaddress(i32 1)56 %1 = call ptr @llvm.eh.recoverfp(ptr @try_except, ptr %0)57 %2 = call ptr @llvm.localrecover(ptr @try_except, ptr %1, i32 0)58 %3 = getelementptr inbounds i8, ptr %0, i32 -2059 %4 = load ptr, ptr %3, align 460 %5 = getelementptr inbounds { ptr, ptr }, ptr %4, i32 0, i32 061 %6 = load ptr, ptr %5, align 462 %7 = load i32, ptr %6, align 463 store i32 %7, ptr %2, align 464 ret i32 165}66 67define void @nested_exceptions() #0 personality ptr @_except_handler3 {68entry:69 %__exception_code = alloca i32, align 470 call void (...) @llvm.localescape(ptr %__exception_code)71 invoke void @crash() #372 to label %__try.cont unwind label %catch.dispatch73 74catch.dispatch: ; preds = %entry75 %cs1 = catchswitch within none [label %__except.ret] unwind label %catch.dispatch.1176 77__except.ret: ; preds = %catch.dispatch78 %0 = catchpad within %cs1 [ptr @nested_exceptions_filter_catchall]79 catchret from %0 to label %__try.cont80 81__try.cont: ; preds = %entry, %__except.ret82 invoke void @crash() #383 to label %__try.cont.9 unwind label %catch.dispatch.584 85catch.dispatch.5: ; preds = %__try.cont86 %cs2 = catchswitch within none [label %__except.ret.7] unwind label %catch.dispatch.1187 88__except.ret.7: ; preds = %catch.dispatch.589 %1 = catchpad within %cs2 [ptr @nested_exceptions_filter_catchall]90 catchret from %1 to label %__try.cont.991 92__try.cont.9: ; preds = %__try.cont, %__except.ret.793 invoke void @crash() #394 to label %__try.cont.15 unwind label %catch.dispatch.1195 96catch.dispatch.11: ; preds = %catchendblock, %catchendblock.6, %__try.cont.997 %cs3 = catchswitch within none [label %__except.ret.13] unwind label %catch.dispatch.1798 99__except.ret.13: ; preds = %catch.dispatch.11100 %2 = catchpad within %cs3 [ptr @nested_exceptions_filter_catchall]101 catchret from %2 to label %__try.cont.15102 103__try.cont.15: ; preds = %__try.cont.9, %__except.ret.13104 invoke void @crash() #3105 to label %__try.cont.35 unwind label %catch.dispatch.17106 107catch.dispatch.17: ; preds = %catchendblock.12, %__try.cont.15108 %cs4 = catchswitch within none [label %__except.ret.19] unwind to caller109 110__except.ret.19: ; preds = %catch.dispatch.17111 %3 = catchpad within %cs4 [ptr @nested_exceptions_filter_catchall]112 catchret from %3 to label %__except.20113 114__except.20: ; preds = %__except.ret.19115 invoke void @crash() #3116 to label %__try.cont.27 unwind label %catch.dispatch.23117 118catch.dispatch.23: ; preds = %__except.20119 %cs5 = catchswitch within none [label %__except.ret.25] unwind to caller120 121__except.ret.25: ; preds = %catch.dispatch.23122 %4 = catchpad within %cs5 [ptr @nested_exceptions_filter_catchall]123 catchret from %4 to label %__try.cont.27124 125__try.cont.27: ; preds = %__except.20, %__except.ret.25126 invoke void @crash() #3127 to label %__try.cont.35 unwind label %catch.dispatch.30128 129catch.dispatch.30: ; preds = %__try.cont.27130 %cs6 = catchswitch within none [label %__except.ret.32] unwind to caller131 132__except.ret.32: ; preds = %catch.dispatch.30133 %5 = catchpad within %cs6 [ptr @nested_exceptions_filter_catchall]134 catchret from %5 to label %__try.cont.35135 136__try.cont.35: ; preds = %__try.cont.15, %__try.cont.27, %__except.ret.32137 ret void138}139 140; This table is equivalent to the one produced by MSVC, even if it isn't in141; quite the same order.142 143; CHECK-LABEL: _nested_exceptions:144; CHECK: L__ehtable$nested_exceptions:145; CHECK: .long -1146; CHECK: .long _nested_exceptions_filter_catchall147; CHECK: .long LBB148; CHECK: .long 0149; CHECK: .long _nested_exceptions_filter_catchall150; CHECK: .long LBB151; CHECK: .long 1152; CHECK: .long _nested_exceptions_filter_catchall153; CHECK: .long LBB154; CHECK: .long 1155; CHECK: .long _nested_exceptions_filter_catchall156; CHECK: .long LBB157; CHECK: .long -1158; CHECK: .long _nested_exceptions_filter_catchall159; CHECK: .long LBB160; CHECK: .long -1161; CHECK: .long _nested_exceptions_filter_catchall162; CHECK: .long LBB163 164declare void @crash() #0165 166define internal i32 @nested_exceptions_filter_catchall() #0 {167entry:168 %0 = call ptr @llvm.frameaddress(i32 1)169 %1 = call ptr @llvm.eh.recoverfp(ptr @nested_exceptions, ptr %0)170 %2 = call ptr @llvm.localrecover(ptr @nested_exceptions, ptr %1, i32 0)171 %3 = getelementptr inbounds i8, ptr %0, i32 -20172 %4 = load ptr, ptr %3, align 4173 %5 = getelementptr inbounds { ptr, ptr }, ptr %4, i32 0, i32 0174 %6 = load ptr, ptr %5, align 4175 %7 = load i32, ptr %6, align 4176 store i32 %7, ptr %2, align 4177 ret i32 1178}179 180define void @code_in_catchpad() #0 personality ptr @_except_handler3 {181entry:182 invoke void @f(i32 1) #3183 to label %__except unwind label %catch.dispatch184 185catch.dispatch: ; preds = %entry186 %cs1 = catchswitch within none [label %__except.ret] unwind to caller187 188__except.ret: ; preds = %catch.dispatch189 %0 = catchpad within %cs1 [ptr @try_except_filter_catchall]190 call void @f(i32 2) [ "funclet"(token %0) ]191 catchret from %0 to label %__except192 193__except:194 ret void195}196 197; CHECK-LABEL: _code_in_catchpad:198; CHECK: # %__except.ret199; CHECK-NEXT: $ehgcr_4_1:200; CHECK-NEXT: movl -24(%ebp), %esp201; CHECK-NEXT: addl $12, %ebp202; CHECK-NEXT: movl $-1, -16(%ebp)203; CHECK-NEXT: pushl $2204; CHECK-NEXT: calll _f205 206 207; Function Attrs: nounwind readnone208declare ptr @llvm.frameaddress(i32) #1209 210; Function Attrs: nounwind readnone211declare ptr @llvm.eh.recoverfp(ptr, ptr) #1212 213; Function Attrs: nounwind readnone214declare ptr @llvm.localrecover(ptr, ptr, i32) #1215 216declare void @f(i32) #0217 218declare i32 @_except_handler3(...)219 220; Function Attrs: nounwind221declare void @llvm.localescape(...) #2222 223attributes #0 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "use-soft-float"="false" }224attributes #1 = { nounwind readnone }225attributes #2 = { nounwind }226attributes #3 = { noinline }227