1 ; RUN: llc -verify-machineinstrs -mtriple=i686-pc-windows-msvc < %s | FileCheck --check-prefix=X86 %s
2 ; RUN: llc -verify-machineinstrs -mtriple=x86_64-pc-windows-msvc < %s | FileCheck --check-prefix=X64 %s
4 %struct.Dtor = type { i8 }
6 define void @simple_cleanup() #0 personality ptr @__CxxFrameHandler3 {
8 %o = alloca %struct.Dtor, align 1
10 to label %invoke.cont unwind label %ehcleanup
12 invoke.cont: ; preds = %entry
13 call x86_thiscallcc void @"\01??1Dtor@@QAE@XZ"(ptr %o) #2
16 ehcleanup: ; preds = %entry
17 %0 = cleanuppad within none []
18 call x86_thiscallcc void @"\01??1Dtor@@QAE@XZ"(ptr %o) #2 [ "funclet"(token %0) ]
19 cleanupret from %0 unwind to caller
22 ; CHECK: simple_cleanup: # @simple_cleanup
24 ; CHECK: subq $48, %rsp
25 ; CHECK: leaq 48(%rsp), %rbp
26 ; CHECK: movq $-2, -8(%rbp)
27 ; CHECK: movl $1, %ecx
29 ; CHECK: callq "??1Dtor@@QAE@XZ"
31 ; CHECK: addq $48, %rsp
35 ; CHECK: "?dtor$2@?0?simple_cleanup@4HA":
36 ; CHECK: callq "??1Dtor@@QAE@XZ"
39 ; CHECK: $cppxdata$simple_cleanup:
40 ; CHECK-NEXT: .long 429065506
42 ; CHECK-NEXT: .long ($stateUnwindMap$simple_cleanup)@IMGREL
46 ; CHECK-NEXT: .long ($ip2state$simple_cleanup)@IMGREL
47 ; UnwindHelp offset should match the -2 store above
48 ; CHECK-NEXT: .long 40
52 declare void @f(i32) #0
54 declare i32 @__CxxFrameHandler3(...)
56 ; Function Attrs: nounwind
57 declare x86_thiscallcc void @"\01??1Dtor@@QAE@XZ"(ptr) #1
59 define void @nested_cleanup() #0 personality ptr @__CxxFrameHandler3 {
61 %o1 = alloca %struct.Dtor, align 8
62 %o2 = alloca %struct.Dtor, align 8
64 to label %invoke.cont unwind label %cleanup.outer
66 invoke.cont: ; preds = %entry
68 to label %invoke.cont.1 unwind label %cleanup.inner
70 invoke.cont.1: ; preds = %invoke.cont
71 call x86_thiscallcc void @"\01??1Dtor@@QAE@XZ"(ptr %o2) #2
73 to label %invoke.cont.2 unwind label %cleanup.outer
75 invoke.cont.2: ; preds = %invoke.cont.1
76 call x86_thiscallcc void @"\01??1Dtor@@QAE@XZ"(ptr %o1) #2
79 cleanup.inner: ; preds = %invoke.cont
80 %0 = cleanuppad within none []
81 call x86_thiscallcc void @"\01??1Dtor@@QAE@XZ"(ptr %o2) #2 [ "funclet"(token %0) ]
82 cleanupret from %0 unwind label %cleanup.outer
84 cleanup.outer: ; preds = %invoke.cont.1, %cleanup.inner, %entry
85 %1 = cleanuppad within none []
86 call x86_thiscallcc void @"\01??1Dtor@@QAE@XZ"(ptr %o1) #2 [ "funclet"(token %1) ]
87 cleanupret from %1 unwind to caller
90 ; X86-LABEL: _nested_cleanup:
98 ; X86: "?dtor$[[cleanup_inner:[0-9]+]]@?0?nested_cleanup@4HA":
99 ; X86: LBB1_[[cleanup_inner]]: # %cleanup.inner{{$}}
101 ; X86: leal {{.*}}(%ebp), %ecx
102 ; X86: calll "??1Dtor@@QAE@XZ"
106 ; X86: "?dtor$[[cleanup_outer:[0-9]+]]@?0?nested_cleanup@4HA":
107 ; X86: LBB1_[[cleanup_outer]]: # %cleanup.outer{{$}}
109 ; X86: leal {{.*}}(%ebp), %ecx
110 ; X86: calll "??1Dtor@@QAE@XZ"
114 ; X86: L__ehtable$nested_cleanup:
115 ; X86: .long 429065506
117 ; X86: .long ($stateUnwindMap$nested_cleanup)
124 ; X86: $stateUnwindMap$nested_cleanup:
126 ; X86: .long "?dtor$[[cleanup_outer]]@?0?nested_cleanup@4HA"
128 ; X86: .long "?dtor$[[cleanup_inner]]@?0?nested_cleanup@4HA"
130 ; X64-LABEL: nested_cleanup:
131 ; X64: .Lfunc_begin1:
139 ; X64: callq "??1Dtor@@QAE@XZ"
145 ; X64: "?dtor$[[cleanup_inner:[0-9]+]]@?0?nested_cleanup@4HA":
146 ; X64: LBB1_[[cleanup_inner]]: # %cleanup.inner{{$}}
148 ; X64: leaq {{.*}}(%rbp), %rcx
149 ; X64: callq "??1Dtor@@QAE@XZ"
153 ; X64: .seh_handlerdata
157 ; X64: "?dtor$[[cleanup_outer:[0-9]+]]@?0?nested_cleanup@4HA":
158 ; X64: LBB1_[[cleanup_outer]]: # %cleanup.outer{{$}}
160 ; X64: leaq {{.*}}(%rbp), %rcx
161 ; X64: callq "??1Dtor@@QAE@XZ"
165 ; X64: .section .xdata,"dr"
166 ; X64-NEXT: .p2align 2
167 ; X64: $cppxdata$nested_cleanup:
168 ; X64-NEXT: .long 429065506
170 ; X64-NEXT: .long ($stateUnwindMap$nested_cleanup)@IMGREL
174 ; X64-NEXT: .long ($ip2state$nested_cleanup)@IMGREL
179 ; X64: $stateUnwindMap$nested_cleanup:
181 ; X64-NEXT: .long "?dtor$[[cleanup_outer]]@?0?nested_cleanup@4HA"@IMGREL
183 ; X64-NEXT: .long "?dtor$[[cleanup_inner]]@?0?nested_cleanup@4HA"@IMGREL
185 ; X64: $ip2state$nested_cleanup:
186 ; X64-NEXT: .long .Lfunc_begin1@IMGREL
188 ; X64-NEXT: .long .Ltmp2@IMGREL
190 ; X64-NEXT: .long .Ltmp4@IMGREL
192 ; X64-NEXT: .long .Ltmp6@IMGREL
194 ; X64-NEXT: .long .Ltmp7@IMGREL+1
197 attributes #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" "unsafe-fp-math"="false" "use-soft-float"="false" }
198 attributes #1 = { nounwind "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" "unsafe-fp-math"="false" "use-soft-float"="false" }
199 attributes #2 = { nounwind }