1 ; RUN: llc < %s | FileCheck %s
3 ; Test case based on this source:
4 ; int puts(const char*);
5 ; __declspec(noinline) void crash() {
6 ; *(volatile int*)0 = 42;
16 ; } __except (filt()) {
21 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
22 target triple = "x86_64-pc-windows-msvc"
24 $"\01??_C@_09KJEHOMHG@__finally?$AA@" = comdat any
26 $"\01??_C@_08MLCMLGHM@__except?$AA@" = comdat any
28 @"\01??_C@_09KJEHOMHG@__finally?$AA@" = linkonce_odr unnamed_addr constant [10 x i8] c"__finally\00", comdat, align 1
29 @"\01??_C@_08MLCMLGHM@__except?$AA@" = linkonce_odr unnamed_addr constant [9 x i8] c"__except\00", comdat, align 1
35 ; Function Attrs: nounwind uwtable
36 define void @use_both() #1 personality ptr @__C_specific_handler {
38 %exn.slot = alloca ptr
39 %ehselector.slot = alloca i32
40 invoke void @crash() #5
41 to label %invoke.cont unwind label %__finally
43 invoke.cont: ; preds = %entry
44 %0 = call ptr @llvm.localaddress()
45 invoke void @"\01?fin$0@0@use_both@@"(i1 zeroext false, ptr %0) #5
46 to label %invoke.cont2 unwind label %catch.dispatch
48 invoke.cont2: ; preds = %invoke.cont
51 __finally: ; preds = %entry
52 %cleanuppad = cleanuppad within none []
53 %locals = call ptr @llvm.localaddress()
54 invoke void @"\01?fin$0@0@use_both@@"(i1 zeroext true, ptr %locals) #5 [ "funclet"(token %cleanuppad) ]
55 to label %invoke.cont3 unwind label %catch.dispatch
57 invoke.cont3: ; preds = %__finally
58 cleanupret from %cleanuppad unwind label %catch.dispatch
60 catch.dispatch: ; preds = %invoke.cont3, %lpad1
61 %cs1 = catchswitch within none [label %__except] unwind to caller
63 __except: ; preds = %catch.dispatch
64 %catchpad = catchpad within %cs1 [ptr @"\01?filt$0@0@use_both@@"]
65 %call = call i32 @puts(ptr @"\01??_C@_08MLCMLGHM@__except?$AA@") [ "funclet"(token %catchpad) ]
66 catchret from %catchpad to label %__try.cont
68 __try.cont: ; preds = %__except, %invoke.cont2
72 ; CHECK-LABEL: use_both:
77 ; CHECK: callq "?fin$0@0@use_both@@"
81 ; CHECK: .seh_handlerdata
82 ; CHECK-NEXT: .Luse_both$parent_frame_offset
83 ; CHECK-NEXT: .long (.Llsda_end0-.Llsda_begin0)/16
84 ; CHECK-NEXT: .Llsda_begin0:
85 ; CHECK-NEXT: .long .Ltmp0@IMGREL
86 ; CHECK-NEXT: .long .Ltmp1@IMGREL+1
87 ; CHECK-NEXT: .long "?dtor$2@?0?use_both@4HA"@IMGREL
89 ; CHECK-NEXT: .long .Ltmp0@IMGREL
90 ; CHECK-NEXT: .long .Ltmp1@IMGREL+1
91 ; CHECK-NEXT: .long "?filt$0@0@use_both@@"@IMGREL
92 ; CHECK-NEXT: .long .LBB0_{{[0-9]+}}@IMGREL
93 ; CHECK-NEXT: .long .Ltmp4@IMGREL
94 ; CHECK-NEXT: .long .Ltmp5@IMGREL+1
95 ; CHECK-NEXT: .long "?filt$0@0@use_both@@"@IMGREL
96 ; CHECK-NEXT: .long .LBB0_{{[0-9]+}}@IMGREL
97 ; CHECK-NEXT: .Llsda_end0:
99 ; Function Attrs: noinline nounwind
100 define internal i32 @"\01?filt$0@0@use_both@@"(ptr %exception_pointers, ptr %frame_pointer) #2 {
102 %frame_pointer.addr = alloca ptr, align 8
103 %exception_pointers.addr = alloca ptr, align 8
104 %exn.slot = alloca ptr
105 store ptr %frame_pointer, ptr %frame_pointer.addr, align 8
106 store ptr %exception_pointers, ptr %exception_pointers.addr, align 8
107 %0 = load ptr, ptr %exception_pointers.addr
108 %1 = getelementptr inbounds { ptr, ptr }, ptr %0, i32 0, i32 0
109 %2 = load ptr, ptr %1
110 %3 = load i32, ptr %2
111 %4 = zext i32 %3 to i64
112 %5 = inttoptr i64 %4 to ptr
113 store ptr %5, ptr %exn.slot
114 %call = call i32 @filt()
118 define internal void @"\01?fin$0@0@use_both@@"(i1 zeroext %abnormal_termination, ptr %frame_pointer) #3 {
120 %frame_pointer.addr = alloca ptr, align 8
121 %abnormal_termination.addr = alloca i8, align 1
122 store ptr %frame_pointer, ptr %frame_pointer.addr, align 8
123 %frombool = zext i1 %abnormal_termination to i8
124 store i8 %frombool, ptr %abnormal_termination.addr, align 1
125 %call = call i32 @puts(ptr @"\01??_C@_09KJEHOMHG@__finally?$AA@")
129 declare i32 @puts(ptr) #3
131 declare i32 @__C_specific_handler(...)
133 ; Function Attrs: nounwind readnone
134 declare ptr @llvm.localaddress() #4
136 ; Function Attrs: nounwind readnone
137 declare i32 @llvm.eh.typeid.for(ptr) #4
139 attributes #0 = { noinline nounwind uwtable "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "unsafe-fp-math"="false" "use-soft-float"="false" }
140 attributes #1 = { nounwind uwtable "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "unsafe-fp-math"="false" "use-soft-float"="false" }
141 attributes #2 = { noinline nounwind "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "unsafe-fp-math"="false" "use-soft-float"="false" }
142 attributes #3 = { "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "unsafe-fp-math"="false" "use-soft-float"="false" }
143 attributes #4 = { nounwind readnone }
144 attributes #5 = { noinline }
145 attributes #6 = { nounwind }