File: funclet.ll

package info (click to toggle)
llvm-toolchain-13 1%3A13.0.1-11
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,418,840 kB
  • sloc: cpp: 5,290,826; ansic: 996,570; asm: 544,593; python: 188,212; objc: 72,027; lisp: 30,291; f90: 25,395; sh: 24,898; javascript: 9,780; pascal: 9,398; perl: 7,484; ml: 5,432; awk: 3,523; makefile: 2,913; xml: 953; cs: 573; fortran: 539
file content (162 lines) | stat: -rw-r--r-- 6,705 bytes parent folder | download | duplicates (3)
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -licm -S | FileCheck %s
; RUN: opt -aa-pipeline=basic-aa -passes='require<aa>,require<targetir>,require<scalar-evolution>,require<opt-remark-emit>,loop(licm)' < %s -S | FileCheck %s

target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
target triple = "i386-pc-windows-msvc18.0.0"

define void @test1(i32* %s, i1 %b) personality i32 (...)* @__CxxFrameHandler3 {
; CHECK-LABEL: @test1(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[TMP0:%.*]] = call i32 @pure_computation()
; CHECK-NEXT:    br label [[WHILE_COND:%.*]]
; CHECK:       while.cond:
; CHECK-NEXT:    br i1 [[B:%.*]], label [[TRY_CONT_LOOPEXIT:%.*]], label [[WHILE_BODY:%.*]]
; CHECK:       while.body:
; CHECK-NEXT:    invoke void @may_throw()
; CHECK-NEXT:    to label [[WHILE_COND]] unwind label [[CATCH_DISPATCH:%.*]]
; CHECK:       catch.dispatch:
; CHECK-NEXT:    [[DOTLCSSA1:%.*]] = phi i32 [ [[TMP0]], [[WHILE_BODY]] ]
; CHECK-NEXT:    [[CS:%.*]] = catchswitch within none [label %catch] unwind to caller
; CHECK:       catch:
; CHECK-NEXT:    [[CP:%.*]] = catchpad within [[CS]] [i8* null, i32 64, i8* null]
; CHECK-NEXT:    store i32 [[DOTLCSSA1]], i32* [[S:%.*]], align 4
; CHECK-NEXT:    catchret from [[CP]] to label [[TRY_CONT:%.*]]
; CHECK:       try.cont.loopexit:
; CHECK-NEXT:    br label [[TRY_CONT]]
; CHECK:       try.cont:
; CHECK-NEXT:    ret void
;
entry:
  br label %while.cond

while.cond:                                       ; preds = %while.body, %entry
  %0 = call i32 @pure_computation()
  br i1 %b, label %try.cont, label %while.body

while.body:                                       ; preds = %while.cond
  invoke void @may_throw()
  to label %while.cond unwind label %catch.dispatch

catch.dispatch:                                   ; preds = %while.body
  %.lcssa1 = phi i32 [ %0, %while.body ]
  %cs = catchswitch within none [label %catch] unwind to caller

catch:                                            ; preds = %catch.dispatch
  %cp = catchpad within %cs [i8* null, i32 64, i8* null]
  store i32 %.lcssa1, i32* %s
  catchret from %cp to label %try.cont

try.cont:                                         ; preds = %catch, %while.cond
  ret void
}

define void @test2(i32* %s, i1 %b) personality i32 (...)* @__CxxFrameHandler3 {
; CHECK-LABEL: @test2(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    br label [[WHILE_COND:%.*]]
; CHECK:       while.cond:
; CHECK-NEXT:    br i1 [[B:%.*]], label [[TRY_CONT:%.*]], label [[WHILE_BODY:%.*]]
; CHECK:       while.body:
; CHECK-NEXT:    invoke void @may_throw()
; CHECK-NEXT:    to label [[WHILE_COND]] unwind label [[CATCH_DISPATCH:%.*]]
; CHECK:       catch.dispatch:
; CHECK-NEXT:    [[CP:%.*]] = cleanuppad within none []
; CHECK-NEXT:    [[TMP0:%.*]] = call i32 @pure_computation() [ "funclet"(token [[CP]]) ]
; CHECK-NEXT:    store i32 [[TMP0]], i32* [[S:%.*]], align 4
; CHECK-NEXT:    cleanupret from [[CP]] unwind to caller
; CHECK:       try.cont:
; CHECK-NEXT:    ret void
;
entry:
  br label %while.cond

while.cond:                                       ; preds = %while.body, %entry
  %0 = call i32 @pure_computation()
  br i1 %b, label %try.cont, label %while.body

while.body:                                       ; preds = %while.cond
  invoke void @may_throw()
  to label %while.cond unwind label %catch.dispatch

catch.dispatch:                                   ; preds = %while.body
  %.lcssa1 = phi i32 [ %0, %while.body ]
  %cp = cleanuppad within none []
  store i32 %.lcssa1, i32* %s
  cleanupret from %cp unwind to caller

try.cont:                                         ; preds = %catch, %while.cond
  ret void
}

define void @test3(i1 %a, i1 %b, i1 %c) personality i32 (...)* @__CxxFrameHandler3 {
; CHECK-LABEL: @test3(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[DOTFRAME:%.*]] = alloca i8, align 4
; CHECK-NEXT:    [[DOTFRAME2:%.*]] = alloca i8, align 4
; CHECK-NEXT:    [[BC:%.*]] = bitcast i8* [[DOTFRAME]] to i32*
; CHECK-NEXT:    [[BC2:%.*]] = bitcast i8* [[DOTFRAME2]] to i32*
; CHECK-NEXT:    br i1 [[A:%.*]], label [[TRY_SUCCESS_OR_CAUGHT:%.*]], label [[FORBODY_PREHEADER:%.*]]
; CHECK:       forbody.preheader:
; CHECK-NEXT:    store i32 1, i32* [[BC]], align 4
; CHECK-NEXT:    store i32 2, i32* [[BC2]], align 4
; CHECK-NEXT:    br label [[FORBODY:%.*]]
; CHECK:       catch.object.Throwable:
; CHECK-NEXT:    [[CP:%.*]] = catchpad within [[CS:%.*]] [i8* null, i32 64, i8* null]
; CHECK-NEXT:    unreachable
; CHECK:       try.success.or.caught.loopexit:
; CHECK-NEXT:    br label [[TRY_SUCCESS_OR_CAUGHT]]
; CHECK:       try.success.or.caught:
; CHECK-NEXT:    ret void
; CHECK:       postinvoke:
; CHECK-NEXT:    br i1 [[B:%.*]], label [[ELSE:%.*]], label [[FORCOND_BACKEDGE:%.*]]
; CHECK:       forcond.backedge:
; CHECK-NEXT:    br i1 [[C:%.*]], label [[TRY_SUCCESS_OR_CAUGHT_LOOPEXIT:%.*]], label [[FORBODY]]
; CHECK:       catch.dispatch:
; CHECK-NEXT:    [[CS]] = catchswitch within none [label %catch.object.Throwable] unwind to caller
; CHECK:       forbody:
; CHECK-NEXT:    invoke void @may_throw()
; CHECK-NEXT:    to label [[POSTINVOKE:%.*]] unwind label [[CATCH_DISPATCH:%.*]]
; CHECK:       else:
; CHECK-NEXT:    invoke void @may_throw()
; CHECK-NEXT:    to label [[FORCOND_BACKEDGE]] unwind label [[CATCH_DISPATCH]]
;
entry:
  %.frame = alloca i8, align 4
  %.frame2 = alloca i8, align 4
  %bc = bitcast i8* %.frame to i32*
  %bc2 = bitcast i8* %.frame2 to i32*
  br i1 %a, label %try.success.or.caught, label %forbody

catch.object.Throwable:                           ; preds = %catch.dispatch
  %cp = catchpad within %cs [i8* null, i32 64, i8* null]
  unreachable

try.success.or.caught:                            ; preds = %forcond.backedge, %0
  ret void

postinvoke:                                       ; preds = %forbody
  br i1 %b, label %else, label %forcond.backedge

forcond.backedge:                                 ; preds = %else, %postinvoke
  br i1 %c, label %try.success.or.caught, label %forbody

catch.dispatch:                                   ; preds = %else, %forbody
  %cs = catchswitch within none [label %catch.object.Throwable] unwind to caller

forbody:                                          ; preds = %forcond.backedge, %0
  store i32 1, i32* %bc, align 4
  store i32 2, i32* %bc2, align 4
  invoke void @may_throw()
  to label %postinvoke unwind label %catch.dispatch

else:                                             ; preds = %postinvoke
  invoke void @may_throw()
  to label %forcond.backedge unwind label %catch.dispatch
}

declare void @may_throw()

declare i32 @pure_computation() nounwind argmemonly readonly willreturn

declare i32 @__CxxFrameHandler3(...)