• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -licm -S | FileCheck %s
2; RUN: opt -aa-pipeline=basic-aa -passes='require<aa>,require<targetir>,require<scalar-evolution>,loop(licm)' < %s -S | FileCheck %s
3
4target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
5target triple = "i386-pc-windows-msvc18.0.0"
6
7define void @test1(i32* %s, i1 %b) personality i32 (...)* @__CxxFrameHandler3 {
8entry:
9  br label %while.cond
10
11while.cond:                                       ; preds = %while.body, %entry
12  %0 = call i32 @pure_computation()
13  br i1 %b, label %try.cont, label %while.body
14
15while.body:                                       ; preds = %while.cond
16  invoke void @may_throw()
17          to label %while.cond unwind label %catch.dispatch
18
19catch.dispatch:                                   ; preds = %while.body
20  %.lcssa1 = phi i32 [ %0, %while.body ]
21  %cs = catchswitch within none [label %catch] unwind to caller
22
23catch:                                            ; preds = %catch.dispatch
24  %cp = catchpad within %cs [i8* null, i32 64, i8* null]
25  store i32 %.lcssa1, i32* %s
26  catchret from %cp to label %try.cont
27
28try.cont:                                         ; preds = %catch, %while.cond
29  ret void
30}
31
32; CHECK-LABEL: define void @test1(
33; CHECK: %[[CALL:.*]] = call i32 @pure_computation()
34; CHECK: phi i32 [ %[[CALL]]
35
36define void @test2(i32* %s, i1 %b) personality i32 (...)* @__CxxFrameHandler3 {
37entry:
38  br label %while.cond
39
40while.cond:                                       ; preds = %while.body, %entry
41  %0 = call i32 @pure_computation()
42  br i1 %b, label %try.cont, label %while.body
43
44while.body:                                       ; preds = %while.cond
45  invoke void @may_throw()
46          to label %while.cond unwind label %catch.dispatch
47
48catch.dispatch:                                   ; preds = %while.body
49  %.lcssa1 = phi i32 [ %0, %while.body ]
50  %cp = cleanuppad within none []
51  store i32 %.lcssa1, i32* %s
52  cleanupret from %cp unwind to caller
53
54try.cont:                                         ; preds = %catch, %while.cond
55  ret void
56}
57
58; CHECK-LABEL: define void @test2(
59; CHECK:      %[[CP:.*]] = cleanuppad within none []
60; CHECK-NEXT: %[[CALL:.*]] = call i32 @pure_computation() [ "funclet"(token %[[CP]]) ]
61; CHECK-NEXT: store i32 %[[CALL]], i32* %s
62; CHECK-NEXT: cleanupret from %[[CP]] unwind to caller
63
64define void @test3(i1 %a, i1 %b, i1 %c) personality i32 (...)* @__CxxFrameHandler3 {
65entry:
66  %.frame = alloca i8, align 4
67  %.frame2 = alloca i8, align 4
68  %bc = bitcast i8* %.frame to i32*
69  %bc2 = bitcast i8* %.frame2 to i32*
70  br i1 %a, label %try.success.or.caught, label %forbody
71
72catch.object.Throwable:                           ; preds = %catch.dispatch
73  %cp = catchpad within %cs [i8* null, i32 64, i8* null]
74  unreachable
75
76try.success.or.caught:                            ; preds = %forcond.backedge, %0
77  ret void
78
79postinvoke:                                       ; preds = %forbody
80  br i1 %b, label %else, label %forcond.backedge
81
82forcond.backedge:                                 ; preds = %else, %postinvoke
83  br i1 %c, label %try.success.or.caught, label %forbody
84
85catch.dispatch:                                   ; preds = %else, %forbody
86  %cs = catchswitch within none [label %catch.object.Throwable] unwind to caller
87
88forbody:                                          ; preds = %forcond.backedge, %0
89  store i32 1, i32* %bc, align 4
90  store i32 2, i32* %bc2, align 4
91  invoke void @may_throw()
92          to label %postinvoke unwind label %catch.dispatch
93
94else:                                             ; preds = %postinvoke
95  invoke void @may_throw()
96          to label %forcond.backedge unwind label %catch.dispatch
97}
98
99; CHECK-LABEL: define void @test3(
100; CHECK:      catchswitch within none
101; CHECK:      store i32 1, i32* %bc, align 4
102; CHECK:      store i32 2, i32* %bc2, align 4
103
104declare void @may_throw()
105
106declare i32 @pure_computation() nounwind argmemonly readonly
107
108declare i32 @__CxxFrameHandler3(...)
109