• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -simplifycfg -S | FileCheck %s
2target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
3
4declare i32 @__gxx_personality_v0(...)
5declare void @fn()
6
7
8; CHECK-LABEL: @test1
9define void @test1() personality i32 (...)* @__gxx_personality_v0 {
10entry:
11; CHECK-LABEL: entry:
12; CHECK: to label %invoke2 unwind label %lpad2
13  invoke void @fn()
14    to label %invoke2 unwind label %lpad1
15
16invoke2:
17; CHECK-LABEL: invoke2:
18; CHECK: to label %invoke.cont unwind label %lpad2
19  invoke void @fn()
20    to label %invoke.cont unwind label %lpad2
21
22invoke.cont:
23  ret void
24
25lpad1:
26  %exn = landingpad {i8*, i32}
27         cleanup
28  br label %shared_resume
29
30lpad2:
31; CHECK-LABEL: lpad2:
32; CHECK: landingpad { i8*, i32 }
33; CHECK-NEXT: cleanup
34; CHECK-NEXT: call void @fn()
35; CHECK-NEXT: ret void
36  %exn2 = landingpad {i8*, i32}
37          cleanup
38  br label %shared_resume
39
40shared_resume:
41  call void @fn()
42  ret void
43}
44
45; Don't trigger if blocks aren't the same/empty
46define void @neg1() personality i32 (...)* @__gxx_personality_v0 {
47; CHECK-LABEL: @neg1
48entry:
49; CHECK-LABEL: entry:
50; CHECK: to label %invoke2 unwind label %lpad1
51  invoke void @fn()
52    to label %invoke2 unwind label %lpad1
53
54invoke2:
55; CHECK-LABEL: invoke2:
56; CHECK: to label %invoke.cont unwind label %lpad2
57  invoke void @fn()
58    to label %invoke.cont unwind label %lpad2
59
60invoke.cont:
61  ret void
62
63lpad1:
64  %exn = landingpad {i8*, i32}
65         filter [0 x i8*] zeroinitializer
66  call void @fn()
67  br label %shared_resume
68
69lpad2:
70  %exn2 = landingpad {i8*, i32}
71          cleanup
72  br label %shared_resume
73
74shared_resume:
75  call void @fn()
76  ret void
77}
78
79; Should not trigger when the landing pads are not the exact same
80define void @neg2() personality i32 (...)* @__gxx_personality_v0 {
81; CHECK-LABEL: @neg2
82entry:
83; CHECK-LABEL: entry:
84; CHECK: to label %invoke2 unwind label %lpad1
85  invoke void @fn()
86    to label %invoke2 unwind label %lpad1
87
88invoke2:
89; CHECK-LABEL: invoke2:
90; CHECK: to label %invoke.cont unwind label %lpad2
91  invoke void @fn()
92    to label %invoke.cont unwind label %lpad2
93
94invoke.cont:
95  ret void
96
97lpad1:
98  %exn = landingpad {i8*, i32}
99         filter [0 x i8*] zeroinitializer
100  br label %shared_resume
101
102lpad2:
103  %exn2 = landingpad {i8*, i32}
104          cleanup
105  br label %shared_resume
106
107shared_resume:
108  call void @fn()
109  ret void
110}
111