• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -simplifycfg -S | FileCheck %s
2
3declare void @bar()
4
5; This testcase checks to see if the simplifycfg pass is converting invoke
6; instructions to call instructions if the handler just rethrows the exception.
7define i32 @test1() personality i32 (...)* @__gxx_personality_v0 {
8; CHECK-LABEL: @test1(
9; CHECK-NEXT: call void @bar(), !prof ![[PROF:[0-9]+]]
10; CHECK-NEXT: ret i32 0
11        invoke void @bar( )
12                        to label %1 unwind label %Rethrow, !prof !0
13        ret i32 0
14Rethrow:
15        %exn = landingpad {i8*, i32}
16                 catch i8* null
17        resume { i8*, i32 } %exn
18}
19
20!0 = !{!"branch_weights", i32 369, i32 2}
21
22define i32 @test2() personality i32 (...)* @__gxx_personality_v0 {
23; CHECK-LABEL: @test2(
24; CHECK-NEXT: call void @bar() [ "foo"(i32 100) ]
25; CHECK-NEXT: ret i32 0
26        invoke void @bar( ) [ "foo"(i32 100) ]
27                        to label %1 unwind label %Rethrow
28        ret i32 0
29Rethrow:
30        %exn = landingpad {i8*, i32}
31                 catch i8* null
32        resume { i8*, i32 } %exn
33}
34
35declare i64 @dummy1()
36declare i64 @dummy2()
37
38; This testcase checks to see if simplifycfg pass can convert two invoke
39; instructions to call instructions if they share a common trivial unwind
40; block.
41define i64 @test3(i1 %cond) personality i32 (...)* @__gxx_personality_v0 {
42entry:
43; CHECK-LABEL: @test3(
44; CHECK: %call1 = call i64 @dummy1()
45; CHECK: %call2 = call i64 @dummy2()
46; CHECK-NOT: resume { i8*, i32 } %lp
47  br i1 %cond, label %br1, label %br2
48
49br1:
50  %call1 = invoke i64 @dummy1()
51          to label %invoke.cont unwind label %lpad1
52
53br2:
54  %call2 = invoke i64 @dummy2()
55          to label %invoke.cont unwind label %lpad2
56
57invoke.cont:
58  %c = phi i64 [%call1, %br1], [%call2, %br2]
59  ret i64 %c
60
61
62lpad1:
63  %0 = landingpad { i8*, i32 }
64          cleanup
65  br label %rethrow
66
67rethrow:
68  %lp = phi { i8*, i32 } [%0, %lpad1], [%1, %lpad2]
69  resume { i8*, i32 } %lp
70
71lpad2:
72  %1 = landingpad { i8*, i32 }
73          cleanup
74  br label %rethrow
75}
76
77declare i32 @__gxx_personality_v0(...)
78
79; CHECK: ![[PROF]] = !{!"branch_weights", i32 371}
80