Skip to content

Commit 0b7dcf7

Browse files
pawosm-armMacDue
andcommitted
[Downstream change] Cherry-pick of [TargetParser] Parse Amazon Linux triple and handle RuntimeLibcalls
Original PR under review: llvm/llvm-project#136114 As the commit introduced by #535 has resulted in a faulty C++ compiler which could not see system-provided standard C++ library, an alternative solution is now being cherry-picked here which appears to work with Amazon Linux 2023. This is an one off change for the ATfL23 release. Downstream issue: #533 Co-authored-by: Benjamin Maxwell <benjamin.maxwell@arm.com>
1 parent 7d244b9 commit 0b7dcf7

6 files changed

Lines changed: 29 additions & 2 deletions

File tree

llvm/include/llvm/IR/RuntimeLibcalls.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,9 @@ struct RuntimeLibcallsInfo {
232232

233233
/// Return true if the target has sincosf/sincos/sincosl functions
234234
static bool hasSinCos(const Triple &TT) {
235-
return TT.isGNUEnvironment() || TT.isOSFuchsia() || TT.isAndroid();
235+
// Downstream issue: #533 (Amazon Linux still not recognized correctly)
236+
return TT.isGNUEnvironment() || TT.isOSFuchsia() || TT.isAmazonLinux() ||
237+
TT.isAndroid();
236238
}
237239

238240
static bool hasSinCos_f32_f64(const Triple &TT) {

llvm/include/llvm/TargetParser/Triple.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,9 @@ class Triple {
293293
OpenEmbedded,
294294
Intel,
295295
Meta,
296-
LastVendorType = Meta
296+
// Downstream issue: #533 (Amazon Linux still not recognized correctly)
297+
Amazon,
298+
LastVendorType = Amazon
297299
};
298300
enum OSType {
299301
UnknownOS,
@@ -1008,6 +1010,12 @@ class Triple {
10081010
getSubArch() == Triple::X86_64SubArch_lfi);
10091011
}
10101012

1013+
/// Downstream issue: #533 (Amazon Linux still not recognized correctly)
1014+
/// Tests whether the target is Amazon Linux.
1015+
bool isAmazonLinux() const {
1016+
return getOS() == Triple::Linux && getVendor() == Triple::Amazon;
1017+
}
1018+
10111019
/// Tests whether the target supports the EHABI exception
10121020
/// handling standard.
10131021
bool isTargetEHABICompatible() const {

llvm/include/llvm/TargetParser/TripleName.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ TRIPLE_VENDOR(SCEI, "scei")
193193
TRIPLE_VENDOR_ALIAS(SCEI, "sie")
194194
TRIPLE_VENDOR(SUSE, "suse")
195195
TRIPLE_VENDOR(Meta, "meta")
196+
// Downstream issue: #533 (Amazon Linux still not recognized correctly)
197+
TRIPLE_VENDOR(Amazon, "amazon")
196198

197199
#undef TRIPLE_VENDOR
198200
#undef TRIPLE_VENDOR_ALIAS

llvm/test/CodeGen/AArch64/veclib-llvm.sincos.ll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --filter "(bl|ptrue)" --version 5
22
; RUN: llc -mtriple=aarch64-gnu-linux -mattr=+neon,+sve -vector-library=sleefgnuabi < %s | FileCheck %s -check-prefix=SLEEF
33
; RUN: llc -mtriple=aarch64-gnu-linux -mattr=+neon,+sve -vector-library=ArmPL < %s | FileCheck %s -check-prefix=ARMPL
4+
; NOTE: Downstream issue: #533 (Amazon Linux still not recognized correctly)
5+
; Check we expand to a vector library call on aarch64-amazon-linux:
6+
; RUN: llc -mtriple=aarch64-amazon-linux -mattr=+neon,+sve -vector-library=sleefgnuabi < %s | FileCheck %s -check-prefix=SLEEF
7+
; RUN: llc -mtriple=aarch64-amazon-linux -mattr=+neon,+sve -vector-library=ArmPL < %s | FileCheck %s -check-prefix=ARMPL
48

59
define void @test_sincos_v4f32(<4 x float> %x, ptr noalias %out_sin, ptr noalias %out_cos) {
610
; SLEEF-LABEL: test_sincos_v4f32:

llvm/test/Transforms/LoopVectorize/AArch64/multiple-result-intrinsics.ll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --filter "(:|sincos|modf|extractvalue|store|with\.overflow)" --version 5
22
; RUN: opt -passes=loop-vectorize -mtriple=aarch64-gnu-linux -mcpu=neoverse-v1 -mattr=+sve < %s -S -o - -debug-only=loop-vectorize 2>%t.1 | FileCheck %s --check-prefix=CHECK
33
; RUN: opt -passes=loop-vectorize -mtriple=aarch64-gnu-linux -mcpu=neoverse-v1 -mattr=+sve -vector-library=ArmPL < %s -S -o - -debug-only=loop-vectorize 2>%t.2 | FileCheck %s --check-prefix=CHECK-ARMPL
4+
; NOTE: Downstream issue: #533 (Amazon Linux still not recognized correctly)
5+
; RUN: opt -passes=loop-vectorize -mtriple=aarch64-amazon-linux -mcpu=neoverse-v1 -mattr=+sve -vector-library=ArmPL < %s -S -o - -debug-only=loop-vectorize 2>%t.3 | FileCheck %s --check-prefix=CHECK-ARMPL
46
; RUN: FileCheck --input-file=%t.1 --check-prefix=CHECK-COST %s
57
; RUN: FileCheck --input-file=%t.2 --check-prefix=CHECK-COST-ARMPL %s
8+
; NOTE: Downstream issue: #533 (Amazon Linux still not recognized correctly)
9+
; Check we vectorize the functions with the vector-library on aarch64-amazon-linux:
10+
; RUN: FileCheck --input-file=%t.3 --check-prefix=CHECK-COST-ARMPL %s
611
; REQUIRES: asserts
712

813
; CHECK-COST-LABEL: sincos_f32

llvm/unittests/TargetParser/TripleTest.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ TEST(TripleTest, ParsedIDs) {
127127
EXPECT_EQ(Triple::Hurd, T.getOS());
128128
EXPECT_EQ(Triple::GNU, T.getEnvironment());
129129

130+
// Downstream issue: #533 (Amazon Linux still not recognized correctly)
131+
T = Triple("aarch64-amazon-linux");
132+
EXPECT_EQ(Triple::aarch64, T.getArch());
133+
EXPECT_EQ(Triple::Amazon, T.getVendor());
134+
EXPECT_EQ(Triple::Linux, T.getOS());
135+
130136
T = Triple("arm-unknown-linux-android16");
131137
EXPECT_EQ(Triple::arm, T.getArch());
132138
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());

0 commit comments

Comments
 (0)