summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/X86/win-catchpad-csrs.ll
blob: 20968cc47390266209683cbc5a3e5dd164f1d742 (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
; 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

%rtti.TypeDescriptor2 = type { i8**, i8*, [3 x i8] }
%eh.CatchableType = type { i32, i8*, i32, i32, i32, i32, i8* }
%eh.CatchableTypeArray.1 = type { i32, [1 x %eh.CatchableType*] }
%eh.ThrowInfo = type { i32, i8*, i8*, i8* }

$"\01??_R0H@8" = comdat any

@"\01??_7type_info@@6B@" = external constant i8*
@"\01??_R0H@8" = linkonce_odr global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".H\00" }, comdat

declare i32 @getint()
declare void @useints(...)
declare void @f(i32 %p)
declare i32 @__CxxFrameHandler3(...)

define i32 @try_catch_catch() personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
entry:
  %a = call i32 @getint()
  %b = call i32 @getint()
  %c = call i32 @getint()
  %d = call i32 @getint()
  call void (...) @useints(i32 %a, i32 %b, i32 %c, i32 %d)
  invoke void @f(i32 1)
          to label %try.cont unwind label %catch.dispatch

catch.dispatch:                                   ; preds = %entry
  %0 = catchpad [%rtti.TypeDescriptor2* @"\01??_R0H@8", i32 0, i8* null]
          to label %catch unwind label %catchendblock

catch:
  invoke void @f(i32 2)
          to label %invoke.cont.2 unwind label %catchendblock

invoke.cont.2:                                    ; preds = %catch
  catchret %0 to label %try.cont

try.cont:                                         ; preds = %entry, %invoke.cont.2, %invoke.cont.3
  ret i32 0

catchendblock:                                    ; preds = %catch,
  catchendpad unwind to caller
}

; X86-LABEL: _try_catch_catch:
; X86: pushl %ebp
; X86: movl %esp, %ebp
; X86: pushl %ebx
; X86: pushl %edi
; X86: pushl %esi
; X86: subl ${{[0-9]+}}, %esp
; X86: calll _getint
; X86: calll _getint
; X86: calll _getint
; X86: calll _getint
; X86: calll _useints
; X86: movl $0, -{{[0-9]+}}(%ebp)
; X86: movl $1, (%esp)
; X86: calll _f
; X86: [[contbb:Ltmp[0-9]+]]: # Block address taken
; X86: movl -{{[0-9]+}}(%ebp), %esp
; X86: addl ${{[0-9]+}}, %esp
; X86: popl %esi
; X86: popl %edi
; X86: popl %ebx
; X86: popl %ebp
; X86: retl

; X86: [[catch1bb:LBB0_[0-9]+]]: # %catch{{$}}
; X86: pushl %ebp
; X86-NOT: pushl
; X86: addl $12, %ebp
; X86: subl $16, %esp
; X86: movl $1, -{{[0-9]+}}(%ebp)
; X86: movl $2, (%esp)
; X86: calll _f
; X86: movl $[[contbb]], %eax
; X86-NEXT: addl $16, %esp
; X86-NEXT: popl %ebp
; X86-NEXT: retl

; X86: L__ehtable$try_catch_catch:
; X86: $handlerMap$0$try_catch_catch:
; X86:   .long   0
; X86:   .long   "??_R0H@8"
; X86:   .long   0
; X86:   .long   [[catch1bb]]

; X64-LABEL: try_catch_catch:
; X64: pushq %rbp
; X64: .seh_pushreg 5
; X64: pushq %rsi
; X64: .seh_pushreg 6
; X64: pushq %rdi
; X64: .seh_pushreg 7
; X64: pushq %rbx
; X64: .seh_pushreg 3
; X64: subq $40, %rsp
; X64: .seh_stackalloc 40
; X64: leaq 32(%rsp), %rbp
; X64: .seh_setframe 5, 32
; X64: callq getint
; X64: callq getint
; X64: callq getint
; X64: callq getint
; X64: callq useints
; X64: movl $1, %ecx
; X64: callq f
; X64: [[contbb:.Ltmp[0-9]+]]: # Block address taken
; X64: addq $40, %rsp
; X64: popq %rbp
; X64: retq

; X64: [[catch1bb:\.LBB0_[0-9]+]]: # %catch{{$}}
; X64: movq %rdx, 16(%rsp)
; X64: pushq %rbp
; X64: movq %rdx, %rbp
; X64: subq $32, %rsp
; X64: movl $2, %ecx
; X64: callq f
; X64: leaq [[contbb]](%rip), %rax
; X64: addq $32, %rsp
; X64: popq %rbp
; X64: retq

; X64: $handlerMap$0$try_catch_catch:
; X64:   .long   0
; X64:   .long   "??_R0H@8"@IMGREL
; X64:   .long   0
; X64:   .long   [[catch1bb]]@IMGREL
; X64:   .long   56
OpenPOWER on IntegriCloud