Skip to content

Commit b042af3

Browse files
authored
[clang codegen] Precommit tests for PR96025, NFC (#98704)
Add extern "C" for the function because there is difference function naming rules between Linux and Windows
1 parent cf6233f commit b042af3

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5
2+
3+
// RUN: %clang_cc1 -fmath-errno -O3 -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefixes=CHECK,NoNewStructPathTBAA
4+
// RUN: %clang_cc1 -fmath-errno -O3 -new-struct-path-tbaa -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefixes=CHECK,NewStructPathTBAA
5+
6+
extern "C" float expf(float);
7+
8+
// Emit int TBAA metadata on FP math libcalls, which is useful for alias analysis
9+
10+
// CHECK-LABEL: define dso_local float @foo(
11+
// CHECK-SAME: ptr nocapture noundef readonly [[NUM:%.*]], float noundef [[R2INV:%.*]], i32 noundef [[N:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
12+
// CHECK-NEXT: [[ENTRY:.*:]]
13+
// CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i8, ptr [[NUM]], i64 40
14+
// CHECK-NEXT: [[TMP0:%.*]] = load float, ptr [[ARRAYIDX]], align 4, !tbaa [[TBAA2:![0-9]+]]
15+
// CHECK-NEXT: [[CALL:%.*]] = tail call float @expf(float noundef [[TMP0]]) #[[ATTR2:[0-9]+]]
16+
// CHECK-NEXT: [[TMP1:%.*]] = load float, ptr [[ARRAYIDX]], align 4, !tbaa [[TBAA2]]
17+
// CHECK-NEXT: [[MUL:%.*]] = fmul float [[CALL]], [[TMP1]]
18+
// CHECK-NEXT: ret float [[MUL]]
19+
//
20+
extern "C" float foo (float num[], float r2inv, int n) {
21+
const float expm2 = expf(num[10]); // Emit TBAA metadata on @expf
22+
float tmp = expm2 * num[10];
23+
return tmp;
24+
}
25+
//.
26+
// NoNewStructPathTBAA: [[TBAA2]] = !{[[META3:![0-9]+]], [[META3]], i64 0}
27+
// NoNewStructPathTBAA: [[META3]] = !{!"float", [[META4:![0-9]+]], i64 0}
28+
// NoNewStructPathTBAA: [[META4]] = !{!"omnipotent char", [[META5:![0-9]+]], i64 0}
29+
// NoNewStructPathTBAA: [[META5]] = !{!"Simple C++ TBAA"}
30+
//.
31+
// NewStructPathTBAA: [[TBAA2]] = !{[[META3:![0-9]+]], [[META3]], i64 0, i64 4}
32+
// NewStructPathTBAA: [[META3]] = !{[[META4:![0-9]+]], i64 4, !"float"}
33+
// NewStructPathTBAA: [[META4]] = !{[[META5:![0-9]+]], i64 1, !"omnipotent char"}
34+
// NewStructPathTBAA: [[META5]] = !{!"Simple C++ TBAA"}
35+
//.
36+
//// NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
37+
// NewStructPathTBAA: {{.*}}
38+
// NoNewStructPathTBAA: {{.*}}

0 commit comments

Comments
 (0)