summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/WinEH/wineh-cleanuppad-nounwind.ll
blob: ff6b70ab190a8265f2207cd73b70f4dbdf0ce24e (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
; RUN: opt -S -winehprepare < %s | FileCheck %s
target triple = "x86_64-pc-windows-msvc"

; CHECK-LABEL: @test1(
define void @test1(i1 %b) personality i32 (...)* @__CxxFrameHandler3 {
entry:
  invoke void @f()
          to label %try.cont unwind label %cleanup.bb

; CHECK: entry:

; CHECK: [[catchswitch_entry:.*]]:
; CHECK-NEXT: %[[cs0:.*]] = catchswitch within none [label %[[catchpad:.*]]] unwind to caller
; CHECK: [[catchpad]]:
; CHECK-NEXT: %[[cp0:.*]] = catchpad within %[[cs0]] [i8* null, i32 64, i8* null]
; CHECK-NEXT: unreachable

try.cont:
  invoke void @f()
          to label %exit unwind label %catchswitch.bb

cleanup.bb:
  %cleanup = cleanuppad within none []
  br i1 %b, label %left, label %right

left:
  call void @exit(i32 0)  [ "funclet"(token %cleanup) ]
  unreachable

right:
  call void @exit(i32 1)  [ "funclet"(token %cleanup) ]
  unreachable

catchswitch.bb:
  %cs = catchswitch within none [label %catchpad.bb] unwind to caller

; CHECK: catchpad.bb:
; CHECK-NEXT:  %catch = catchpad within %cs [i8* null, i32 64, i8* null]

; CHECK: [[catchswitch_catch:.*]]:
; CHECK-NEXT: %[[cs1:.*]] = catchswitch within %catch [label %[[catchpad_catch:.*]]] unwind to caller
; CHECK: [[catchpad_catch]]:
; CHECK-NEXT: %[[cp1:.*]] = catchpad within %[[cs1]] [i8* null, i32 64, i8* null]
; CHECK-NEXT: unreachable

; CHECK: nested.cleanup.bb:
; CHECK-NEXT:  %nested.cleanup = cleanuppad within %catch []
; CHECK-NEXT:  call void @exit(i32 2)  [ "funclet"(token %nested.cleanup) ]
; CHECK-NEXT:  cleanupret from %nested.cleanup unwind label %[[catchswitch_catch]]

catchpad.bb:
  %catch = catchpad within %cs [i8* null, i32 64, i8* null]
  invoke void @f() [ "funclet"(token %catch) ]
          to label %unreachable unwind label %nested.cleanup.bb

nested.cleanup.bb:
  %nested.cleanup = cleanuppad within %catch []
  call void @exit(i32 2)  [ "funclet"(token %nested.cleanup) ]
  unreachable

unreachable:
  unreachable

exit:
  unreachable
}

; CHECK-LABEL: @test2(
define void @test2(i1 %B) personality i32 (...)* @__CxxFrameHandler3 {
entry:
  invoke void @f()
          to label %invoke.cont unwind label %ehcleanup

invoke.cont:
  unreachable

ehcleanup:
  %cp = cleanuppad within none []
  br i1 %B, label %ret, label %if.then

if.then:
  call void @exit(i32 1) [ "funclet"(token %cp) ]
  unreachable

ret:
  cleanupret from %cp unwind to caller
}

; CHECK: call void @exit(i32 1) [ "funclet"(token %cp) ]
; CHECK-NEXT: unreachable

declare void @f()
declare void @exit(i32) nounwind noreturn

declare i32 @__CxxFrameHandler3(...)
OpenPOWER on IntegriCloud