Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / pr58798.cpp
blob607b36aa7f69a9714705fd5cf0e8b4d48e02e530
1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --check-attributes
2 // RUN: %clang_cc1 -emit-llvm %s -o - -triple x86_64-linux-gnu -fexceptions -fcxx-exceptions | FileCheck %s
4 // CHECK: Function Attrs: mustprogress noinline nounwind optnone willreturn memory(read)
5 // CHECK-LABEL: define {{[^@]+}}@_Z54early_caller_of_callee_with_clang_attr_with_clang_attri
6 // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR0:[0-9]+]] {
7 // CHECK-NEXT: entry:
8 // CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4
9 // CHECK-NEXT: store i32 [[A]], ptr [[A_ADDR]], align 4
10 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4
11 // CHECK-NEXT: [[CALL:%.*]] = call noundef i32 @_Z22callee_with_clang_attri(i32 noundef [[TMP0]]) #[[ATTR3:[0-9]+]]
12 // CHECK-NEXT: ret i32 [[CALL]]
15 // CHECK: Function Attrs: mustprogress noinline nounwind optnone willreturn memory(read)
16 // CHECK-LABEL: define {{[^@]+}}@_Z22callee_with_clang_attri
17 // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR0]] {
18 // CHECK-NEXT: entry:
19 // CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4
20 // CHECK-NEXT: store i32 [[A]], ptr [[A_ADDR]], align 4
21 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4
22 // CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[TMP0]], 0
23 // CHECK-NEXT: br i1 [[TOBOOL]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
24 // CHECK: if.then:
25 // CHECK-NEXT: [[EXCEPTION:%.*]] = call ptr @__cxa_allocate_exception(i64 4) #[[ATTR4:[0-9]+]]
26 // CHECK-NEXT: store i32 42, ptr [[EXCEPTION]], align 16
27 // CHECK-NEXT: call void @__cxa_throw(ptr [[EXCEPTION]], ptr @_ZTIi, ptr null) #[[ATTR5:[0-9]+]]
28 // CHECK-NEXT: unreachable
29 // CHECK: if.end:
30 // CHECK-NEXT: ret i32 24
33 // CHECK: Function Attrs: mustprogress noinline nounwind optnone
34 // CHECK-LABEL: define {{[^@]+}}@_Z52early_caller_of_callee_with_clang_attr_with_cxx_attri
35 // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR1:[0-9]+]] {
36 // CHECK-NEXT: entry:
37 // CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4
38 // CHECK-NEXT: store i32 [[A]], ptr [[A_ADDR]], align 4
39 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4
40 // CHECK-NEXT: [[CALL:%.*]] = call noundef i32 @_Z22callee_with_clang_attri(i32 noundef [[TMP0]]) #[[ATTR3]]
41 // CHECK-NEXT: ret i32 [[CALL]]
44 // CHECK: Function Attrs: mustprogress noinline nounwind optnone willreturn memory(read)
45 // CHECK-LABEL: define {{[^@]+}}@_Z52early_caller_of_callee_with_cxx_attr_with_clang_attri
46 // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR0]] {
47 // CHECK-NEXT: entry:
48 // CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4
49 // CHECK-NEXT: store i32 [[A]], ptr [[A_ADDR]], align 4
50 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4
51 // CHECK-NEXT: [[CALL:%.*]] = call noundef i32 @_Z20callee_with_cxx_attri(i32 noundef [[TMP0]]) #[[ATTR4]]
52 // CHECK-NEXT: ret i32 [[CALL]]
55 // CHECK: Function Attrs: mustprogress noinline nounwind optnone
56 // CHECK-LABEL: define {{[^@]+}}@_Z20callee_with_cxx_attri
57 // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR1]] personality ptr @__gxx_personality_v0 {
58 // CHECK-NEXT: entry:
59 // CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4
60 // CHECK-NEXT: store i32 [[A]], ptr [[A_ADDR]], align 4
61 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4
62 // CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[TMP0]], 0
63 // CHECK-NEXT: br i1 [[TOBOOL]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
64 // CHECK: if.then:
65 // CHECK-NEXT: [[EXCEPTION:%.*]] = call ptr @__cxa_allocate_exception(i64 4) #[[ATTR4]]
66 // CHECK-NEXT: store i32 42, ptr [[EXCEPTION]], align 16
67 // CHECK-NEXT: invoke void @__cxa_throw(ptr [[EXCEPTION]], ptr @_ZTIi, ptr null) #[[ATTR5]]
68 // CHECK-NEXT: to label [[UNREACHABLE:%.*]] unwind label [[TERMINATE_LPAD:%.*]]
69 // CHECK: if.end:
70 // CHECK-NEXT: ret i32 24
71 // CHECK: terminate.lpad:
72 // CHECK-NEXT: [[TMP1:%.*]] = landingpad { ptr, i32 }
73 // CHECK-NEXT: catch ptr null
74 // CHECK-NEXT: [[TMP2:%.*]] = extractvalue { ptr, i32 } [[TMP1]], 0
75 // CHECK-NEXT: call void @__clang_call_terminate(ptr [[TMP2]]) #[[ATTR6:[0-9]+]]
76 // CHECK-NEXT: unreachable
77 // CHECK: unreachable:
78 // CHECK-NEXT: unreachable
81 // CHECK: Function Attrs: mustprogress noinline nounwind optnone
82 // CHECK-LABEL: define {{[^@]+}}@_Z50early_caller_of_callee_with_cxx_attr_with_cxx_attri
83 // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR1]] {
84 // CHECK-NEXT: entry:
85 // CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4
86 // CHECK-NEXT: store i32 [[A]], ptr [[A_ADDR]], align 4
87 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4
88 // CHECK-NEXT: [[CALL:%.*]] = call noundef i32 @_Z20callee_with_cxx_attri(i32 noundef [[TMP0]]) #[[ATTR4]]
89 // CHECK-NEXT: ret i32 [[CALL]]
93 // Forward declarations:
95 __attribute__((pure)) int callee_with_clang_attr(int a);
96 int callee_with_cxx_attr(int a) noexcept;
98 // Calls to forward declarations:
100 __attribute__((pure)) int early_caller_of_callee_with_clang_attr_with_clang_attr(int a) {
101 return callee_with_clang_attr(a);
104 int early_caller_of_callee_with_clang_attr_with_cxx_attr(int a) noexcept {
105 return callee_with_clang_attr(a);
108 __attribute__((pure)) int early_caller_of_callee_with_cxx_attr_with_clang_attr(int a) {
109 return callee_with_cxx_attr(a);
112 int early_caller_of_callee_with_cxx_attr_with_cxx_attr(int a) noexcept {
113 return callee_with_cxx_attr(a);
116 // Definitions:
118 __attribute__((pure)) int callee_with_clang_attr(int a) {
119 if(a)
120 throw int(42);
121 return 24;
124 int callee_with_cxx_attr(int a) noexcept {
125 if(a)
126 throw int(42);
127 return 24;
130 // Calls to definitions:
132 // CHECK: Function Attrs: mustprogress noinline nounwind optnone willreturn memory(read)
133 // CHECK-LABEL: define {{[^@]+}}@_Z53late_caller_of_callee_with_clang_attr_with_clang_attri
134 // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR0]] {
135 // CHECK-NEXT: entry:
136 // CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4
137 // CHECK-NEXT: store i32 [[A]], ptr [[A_ADDR]], align 4
138 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4
139 // CHECK-NEXT: [[CALL:%.*]] = call noundef i32 @_Z22callee_with_clang_attri(i32 noundef [[TMP0]]) #[[ATTR3]]
140 // CHECK-NEXT: ret i32 [[CALL]]
142 __attribute__((pure)) int late_caller_of_callee_with_clang_attr_with_clang_attr(int a) {
143 return callee_with_clang_attr(a);
146 // CHECK: Function Attrs: mustprogress noinline nounwind optnone
147 // CHECK-LABEL: define {{[^@]+}}@_Z51late_caller_of_callee_with_clang_attr_with_cxx_attri
148 // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR1]] {
149 // CHECK-NEXT: entry:
150 // CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4
151 // CHECK-NEXT: store i32 [[A]], ptr [[A_ADDR]], align 4
152 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4
153 // CHECK-NEXT: [[CALL:%.*]] = call noundef i32 @_Z22callee_with_clang_attri(i32 noundef [[TMP0]]) #[[ATTR3]]
154 // CHECK-NEXT: ret i32 [[CALL]]
156 int late_caller_of_callee_with_clang_attr_with_cxx_attr(int a) noexcept {
157 return callee_with_clang_attr(a);
160 // CHECK: Function Attrs: mustprogress noinline nounwind optnone willreturn memory(read)
161 // CHECK-LABEL: define {{[^@]+}}@_Z51late_caller_of_callee_with_cxx_attr_with_clang_attri
162 // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR0]] {
163 // CHECK-NEXT: entry:
164 // CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4
165 // CHECK-NEXT: store i32 [[A]], ptr [[A_ADDR]], align 4
166 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4
167 // CHECK-NEXT: [[CALL:%.*]] = call noundef i32 @_Z20callee_with_cxx_attri(i32 noundef [[TMP0]]) #[[ATTR4]]
168 // CHECK-NEXT: ret i32 [[CALL]]
170 __attribute__((pure)) int late_caller_of_callee_with_cxx_attr_with_clang_attr(int a) {
171 return callee_with_cxx_attr(a);
174 // CHECK: Function Attrs: mustprogress noinline nounwind optnone
175 // CHECK-LABEL: define {{[^@]+}}@_Z49late_caller_of_callee_with_cxx_attr_with_cxx_attri
176 // CHECK-SAME: (i32 noundef [[A:%.*]]) #[[ATTR1]] {
177 // CHECK-NEXT: entry:
178 // CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4
179 // CHECK-NEXT: store i32 [[A]], ptr [[A_ADDR]], align 4
180 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4
181 // CHECK-NEXT: [[CALL:%.*]] = call noundef i32 @_Z20callee_with_cxx_attri(i32 noundef [[TMP0]]) #[[ATTR4]]
182 // CHECK-NEXT: ret i32 [[CALL]]
184 int late_caller_of_callee_with_cxx_attr_with_cxx_attr(int a) noexcept {
185 return callee_with_cxx_attr(a);