[PATCH] D93585: [AArch64][Clang][Linux] Enable out-of-line atomics by default.
Pavel Iliin via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 27 16:04:03 PST 2021
ilinpv updated this revision to Diff 319693.
ilinpv added a comment.
Clang driver tests for outline atomics were added.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93585/new/
https://reviews.llvm.org/D93585
Files:
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/Linux.cpp
clang/lib/Driver/ToolChains/Linux.h
clang/test/Driver/aarch64-features.c
Index: clang/test/Driver/aarch64-features.c
===================================================================
--- clang/test/Driver/aarch64-features.c
+++ clang/test/Driver/aarch64-features.c
@@ -6,3 +6,13 @@
// The AArch64 PCS states that chars should be unsigned.
// CHECK: fno-signed-char
+// Check for AArch64 out-of-line atomics default settings.
+// RUN: %clang -target aarch64-linux-android -rtlib=compiler-rt -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
+// RUN: %clang -target aarch64-linux-gnu -rtlib=compiler-rt -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
+// RUN: %clang -target arm64-unknown-linux -rtlib=compiler-rt -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
+// RUN: %clang -target aarch64--none-eabi -rtlib=compiler-rt -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+// RUN: %clang -target aarch64-apple-darwin -rtlib=compiler-rt -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+// RUN: %clang -target aarch64-windows-gnu -rtlib=compiler-rt -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+// RUN: %clang -target aarch64-unknown-openbsd -rtlib=compiler-rt -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+// CHECK-OUTLINE-ATOMICS-ON: "-target-feature" "+outline-atomics"
+// CHECK-OUTLINE-ATOMICS-OFF-NOT: "-target-feature" "+outline-atomics"
Index: clang/lib/Driver/ToolChains/Linux.h
===================================================================
--- clang/lib/Driver/ToolChains/Linux.h
+++ clang/lib/Driver/ToolChains/Linux.h
@@ -36,6 +36,8 @@
void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
CXXStdlibType GetDefaultCXXStdlibType() const override;
+ bool
+ IsAArch64OutlineAtomicsDefault(const llvm::opt::ArgList &Args) const override;
bool isPIEDefault() const override;
bool isNoExecStackDefault() const override;
bool IsMathErrnoDefault() const override;
Index: clang/lib/Driver/ToolChains/Linux.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -845,6 +845,21 @@
getTriple().isMusl() || getSanitizerArgs().requiresPIE();
}
+bool Linux::IsAArch64OutlineAtomicsDefault(const ArgList &Args) const {
+ if (!getTriple().isAArch64())
+ return false;
+ // Outline atomics for AArch64 are supported by compiler-rt
+ // and libgcc since 9.3.1
+ if (GetRuntimeLibType(Args) == ToolChain::RLT_Libgcc) {
+ const GCCVersion &Ver = GCCInstallation.getVersion();
+ if (Ver.isOlderThan(9, 3, 1))
+ return false;
+ } else if (GetRuntimeLibType(Args) != ToolChain::RLT_CompilerRT) {
+ return false;
+ }
+ return true;
+}
+
bool Linux::isNoExecStackDefault() const {
return getTriple().isAndroid();
}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6481,6 +6481,12 @@
CmdArgs.push_back("-target-feature");
CmdArgs.push_back("-outline-atomics");
}
+ } else {
+ if (Triple.isAArch64() &&
+ getToolChain().IsAArch64OutlineAtomicsDefault(Args)) {
+ CmdArgs.push_back("-target-feature");
+ CmdArgs.push_back("+outline-atomics");
+ }
}
if (Args.hasFlag(options::OPT_faddrsig, options::OPT_fno_addrsig,
Index: clang/include/clang/Driver/ToolChain.h
===================================================================
--- clang/include/clang/Driver/ToolChain.h
+++ clang/include/clang/Driver/ToolChain.h
@@ -456,6 +456,12 @@
/// by default.
virtual bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const;
+ /// Test whether this toolchain supports outline atomics by default.
+ virtual bool
+ IsAArch64OutlineAtomicsDefault(const llvm::opt::ArgList &Args) const {
+ return false;
+ }
+
/// Test whether this toolchain defaults to PIC.
virtual bool isPICDefault() const = 0;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93585.319693.patch
Type: text/x-patch
Size: 4154 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210128/3cc1b8af/attachment.bin>
More information about the cfe-commits
mailing list