https://github.com/vfdff updated https://github.com/llvm/llvm-project/pull/98704
>From 1b8503202474c15aa46fc4cc9151003a8d3ca336 Mon Sep 17 00:00:00 2001 From: zhongyunde 00443407 <zhongyu...@huawei.com> Date: Fri, 12 Jul 2024 21:09:46 -0400 Subject: [PATCH 1/2] [test] Precommit tests for PR96025, NFC --- clang/test/CodeGen/math-libcalls-tbaa.cpp | 38 +++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 clang/test/CodeGen/math-libcalls-tbaa.cpp diff --git a/clang/test/CodeGen/math-libcalls-tbaa.cpp b/clang/test/CodeGen/math-libcalls-tbaa.cpp new file mode 100644 index 0000000000000..d67114fba6614 --- /dev/null +++ b/clang/test/CodeGen/math-libcalls-tbaa.cpp @@ -0,0 +1,38 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 + +// RUN: %clang_cc1 -fmath-errno -O3 -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefixes=CHECK,NoNewStructPathTBAA +// RUN: %clang_cc1 -fmath-errno -O3 -new-struct-path-tbaa -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefixes=CHECK,NewStructPathTBAA + +extern "C" float expf(float); + +// Emit int TBAA metadata on FP math libcalls, which is useful for alias analysis + +// CHECK-LABEL: define dso_local noundef float @_Z3fooPffi( +// CHECK-SAME: ptr nocapture noundef readonly [[NUM:%.*]], float noundef [[R2INV:%.*]], i32 noundef [[N:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i8, ptr [[NUM]], i64 40 +// CHECK-NEXT: [[TMP0:%.*]] = load float, ptr [[ARRAYIDX]], align 4, !tbaa [[TBAA2:![0-9]+]] +// CHECK-NEXT: [[CALL:%.*]] = tail call float @expf(float noundef [[TMP0]]) #[[ATTR2:[0-9]+]] +// CHECK-NEXT: [[TMP1:%.*]] = load float, ptr [[ARRAYIDX]], align 4, !tbaa [[TBAA2]] +// CHECK-NEXT: [[MUL:%.*]] = fmul float [[CALL]], [[TMP1]] +// CHECK-NEXT: ret float [[MUL]] +// +float foo (float num[], float r2inv, int n) { + const float expm2 = expf(num[10]); // Emit TBAA metadata on @expf + float tmp = expm2 * num[10]; + return tmp; +} +//. +// NoNewStructPathTBAA: [[TBAA2]] = !{[[META3:![0-9]+]], [[META3]], i64 0} +// NoNewStructPathTBAA: [[META3]] = !{!"float", [[META4:![0-9]+]], i64 0} +// NoNewStructPathTBAA: [[META4]] = !{!"omnipotent char", [[META5:![0-9]+]], i64 0} +// NoNewStructPathTBAA: [[META5]] = !{!"Simple C++ TBAA"} +//. +// NewStructPathTBAA: [[TBAA2]] = !{[[META3:![0-9]+]], [[META3]], i64 0, i64 4} +// NewStructPathTBAA: [[META3]] = !{[[META4:![0-9]+]], i64 4, !"float"} +// NewStructPathTBAA: [[META4]] = !{[[META5:![0-9]+]], i64 1, !"omnipotent char"} +// NewStructPathTBAA: [[META5]] = !{!"Simple C++ TBAA"} +//. +//// NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: +// NewStructPathTBAA: {{.*}} +// NoNewStructPathTBAA: {{.*}} >From 6f8ec030c56d8fa9d0ad10c8963adc2b3d2f33ee Mon Sep 17 00:00:00 2001 From: Zhongyunde <zhongyu...@huawei.com> Date: Tue, 16 Jul 2024 14:20:37 +0800 Subject: [PATCH 2/2] Fix the checking fail with window's output --- clang/test/CodeGen/math-libcalls-tbaa.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/test/CodeGen/math-libcalls-tbaa.cpp b/clang/test/CodeGen/math-libcalls-tbaa.cpp index d67114fba6614..5b93079492bc5 100644 --- a/clang/test/CodeGen/math-libcalls-tbaa.cpp +++ b/clang/test/CodeGen/math-libcalls-tbaa.cpp @@ -7,7 +7,7 @@ extern "C" float expf(float); // Emit int TBAA metadata on FP math libcalls, which is useful for alias analysis -// CHECK-LABEL: define dso_local noundef float @_Z3fooPffi( +// CHECK-LABEL: define dso_local float @foo( // CHECK-SAME: ptr nocapture noundef readonly [[NUM:%.*]], float noundef [[R2INV:%.*]], i32 noundef [[N:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { // CHECK-NEXT: [[ENTRY:.*:]] // CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i8, ptr [[NUM]], i64 40 @@ -17,7 +17,7 @@ extern "C" float expf(float); // CHECK-NEXT: [[MUL:%.*]] = fmul float [[CALL]], [[TMP1]] // CHECK-NEXT: ret float [[MUL]] // -float foo (float num[], float r2inv, int n) { +extern "C" float foo (float num[], float r2inv, int n) { const float expm2 = expf(num[10]); // Emit TBAA metadata on @expf float tmp = expm2 * num[10]; return tmp; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits