summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/X86/win-cleanuppad.ll
blob: 808e322751d161834eb9bed556ee5d0d21bef1e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
; RUN: llc -mtriple=i686-pc-windows-msvc < %s | FileCheck --check-prefix=X86 %s
; RUN: llc -mtriple=x86_64-pc-windows-msvc < %s | FileCheck --check-prefix=X64 %s

%struct.Dtor = type { i8 }

define void @simple_cleanup() #0 personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
entry:
  %o = alloca %struct.Dtor, align 1
  invoke void @f(i32 1)
          to label %invoke.cont unwind label %ehcleanup

invoke.cont:                                      ; preds = %entry
  call x86_thiscallcc void @"\01??1Dtor@@QAE@XZ"(%struct.Dtor* %o) #2
  ret void

ehcleanup:                                        ; preds = %entry
  %0 = cleanuppad []
  call x86_thiscallcc void @"\01??1Dtor@@QAE@XZ"(%struct.Dtor* %o) #2
  cleanupret %0 unwind to caller
}

declare void @f(i32) #0

declare i32 @__CxxFrameHandler3(...)

; Function Attrs: nounwind
declare x86_thiscallcc void @"\01??1Dtor@@QAE@XZ"(%struct.Dtor*) #1

define void @nested_cleanup() #0 personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
entry:
  %o1 = alloca %struct.Dtor, align 1
  %o2 = alloca %struct.Dtor, align 1
  invoke void @f(i32 1)
          to label %invoke.cont unwind label %cleanup.outer

invoke.cont:                                      ; preds = %entry
  invoke void @f(i32 2)
          to label %invoke.cont.1 unwind label %cleanup.inner

invoke.cont.1:                                    ; preds = %invoke.cont
  call x86_thiscallcc void @"\01??1Dtor@@QAE@XZ"(%struct.Dtor* %o2) #2
  invoke void @f(i32 3)
          to label %invoke.cont.2 unwind label %cleanup.outer

invoke.cont.2:                                    ; preds = %invoke.cont.1
  call x86_thiscallcc void @"\01??1Dtor@@QAE@XZ"(%struct.Dtor* %o1) #2
  ret void

cleanup.inner:                                        ; preds = %invoke.cont
  %0 = cleanuppad []
  call x86_thiscallcc void @"\01??1Dtor@@QAE@XZ"(%struct.Dtor* %o2) #2
  cleanupret %0 unwind label %cleanup.outer

cleanup.outer:                                      ; preds = %invoke.cont.1, %cleanup.inner, %entry
  %1 = cleanuppad []
  call x86_thiscallcc void @"\01??1Dtor@@QAE@XZ"(%struct.Dtor* %o1) #2
  cleanupret %1 unwind to caller
}

; X86-LABEL: _nested_cleanup:
; X86: movl    $1, (%esp)
; X86: calll   _f
; X86: movl    $2, (%esp)
; X86: calll   _f
; X86: movl    $3, (%esp)
; X86: calll   _f

; X86: LBB1_[[cleanup_inner:[0-9]+]]: # %cleanup.inner
; X86: pushl %ebp
; X86: leal    {{.*}}(%ebp), %ecx
; X86: calll   "??1Dtor@@QAE@XZ"
; X86: popl %ebp
; X86: retl

; X86: LBB1_[[cleanup_outer:[0-9]+]]: # %cleanup.outer
; X86: pushl %ebp
; X86: leal    {{.*}}(%ebp), %ecx
; X86: calll   "??1Dtor@@QAE@XZ"
; X86: popl %ebp
; X86: retl

; X86: L__ehtable$nested_cleanup:
; X86:         .long   429065506
; X86:         .long   2
; X86:         .long   ($stateUnwindMap$nested_cleanup)
; X86:         .long   0
; X86:         .long   0
; X86:         .long   0
; X86:         .long   0
; X86:         .long   0
; X86:         .long   1
; X86: $stateUnwindMap$nested_cleanup:
; X86:         .long   -1
; X86:         .long   LBB1_[[cleanup_outer]]
; X86:         .long   0
; X86:         .long   LBB1_[[cleanup_inner]]

; X64-LABEL: nested_cleanup:
; X64: movl    $1, %ecx
; X64: callq   f
; X64: movl    $2, %ecx
; X64: callq   f
; X64: movl    $3, %ecx
; X64: callq   f

; X64: .LBB1_[[cleanup_inner:[0-9]+]]: # %cleanup.inner
; X64: pushq %rbp
; X64: leaq    {{.*}}(%rbp), %rcx
; X64: callq   "??1Dtor@@QAE@XZ"
; X64: popq %rbp
; X64: retq

; X64: .LBB1_[[cleanup_outer:[0-9]+]]: # %cleanup.outer
; X64: pushq %rbp
; X64: leaq    {{.*}}(%rbp), %rcx
; X64: callq   "??1Dtor@@QAE@XZ"
; X64: popq %rbp
; X64: retq

; X64:        .seh_handlerdata
; X64:        .long   ($cppxdata$nested_cleanup)@IMGREL
; X64:        .align  4
; X64:$cppxdata$nested_cleanup:
; X64:        .long   429065506
; X64:        .long   2
; X64:        .long   ($stateUnwindMap$nested_cleanup)@IMGREL
; X64:        .long   0
; X64:        .long   0
; X64:        .long   1
; X64:        .long   ($ip2state$nested_cleanup)@IMGREL
; X64:        .long   40
; X64:        .long   0
; X64:        .long   1
; X64:$stateUnwindMap$nested_cleanup:
; X64:        .long   -1
; X64:        .long   .LBB1_[[cleanup_outer]]@IMGREL
; X64:        .long   0
; X64:        .long   .LBB1_[[cleanup_inner]]@IMGREL
; FIXME: The ip2state table is totally wrong.
; X64:$ip2state$nested_cleanup:
; X64:        .long   .Lfunc_begin1@IMGREL
; X64:        .long   -1

attributes #0 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "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" }
attributes #1 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "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" }
attributes #2 = { nounwind }
OpenPOWER on IntegriCloud