[llvm] d8c6d08 - [PowerPC][PCRelative] Set TLS unsupported with PC relative memops
Kamau Bridgeman via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 7 08:56:42 PDT 2020
Author: Kamau Bridgeman
Date: 2020-08-07T10:56:24-05:00
New Revision: d8c6d083c954b03855700e16c81b483d2ae654d0
URL: https://github.com/llvm/llvm-project/commit/d8c6d083c954b03855700e16c81b483d2ae654d0
DIFF: https://github.com/llvm/llvm-project/commit/d8c6d083c954b03855700e16c81b483d2ae654d0.diff
LOG: [PowerPC][PCRelative] Set TLS unsupported with PC relative memops
Introduce a fatal error if any thread local storage code is compiled
using pc relative memory operations as well as a hidden override
option `-enable-ppc-pcrel-tls` so that this support can be incrementally
added if possible.
Reviewed By: #powerpc, nemanjai
Differential Revision: https://reviews.llvm.org/D85448
Added:
llvm/test/CodeGen/PowerPC/pcrel-tls.ll
Modified:
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index 1786edf9e198..8a14a271df30 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -121,6 +121,11 @@ cl::desc("don't always align innermost loop to 32 bytes on ppc"), cl::Hidden);
static cl::opt<bool> UseAbsoluteJumpTables("ppc-use-absolute-jumptables",
cl::desc("use absolute jump tables on ppc"), cl::Hidden);
+static cl::opt<bool> EnablePPCPCRelTLS(
+ "enable-ppc-pcrel-tls",
+ cl::desc("enable the use of PC relative memops in TLS instructions on PPC"),
+ cl::Hidden);
+
STATISTIC(NumTailCalls, "Number of tail calls");
STATISTIC(NumSiblingCalls, "Number of sibling calls");
STATISTIC(ShufflesHandledWithVPERM, "Number of shuffles lowered to a VPERM");
@@ -2920,6 +2925,9 @@ SDValue PPCTargetLowering::LowerGlobalTLSAddress(SDValue Op,
// which is the most useful form. Eventually support for small and
// large models could be added if users need it, at the cost of
// additional complexity.
+ if (Subtarget.isUsingPCRelativeCalls() && !EnablePPCPCRelTLS)
+ report_fatal_error("Thread local storage is not supported with pc-relative"
+ " addressing - please compile with -mno-pcrel");
GlobalAddressSDNode *GA = cast<GlobalAddressSDNode>(Op);
if (DAG.getTarget().useEmulatedTLS())
return LowerToTLSEmulatedModel(GA, DAG);
diff --git a/llvm/test/CodeGen/PowerPC/pcrel-tls.ll b/llvm/test/CodeGen/PowerPC/pcrel-tls.ll
new file mode 100644
index 000000000000..a40021c14e97
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/pcrel-tls.ll
@@ -0,0 +1,16 @@
+; RUN: not --crash llc -mcpu=pwr10 -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN: -verify-machineinstrs -mattr=+pcrelative-memops -o - < %s 2>&1 | \
+; RUN: FileCheck %s --check-prefix=CHECK-PCREL
+; RUN: llc -mcpu=pwr10 -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN: -verify-machineinstrs -mattr=-pcrelative-memops -o - < %s 2>&1 | \
+; RUN: FileCheck %s --check-prefix=CHECK-NOPCREL
+
+; CHECK-PCREL: Thread local storage is not supported with pc-relative addressing
+; CHECK-NOPCREL: blr
+
+ at x = external thread_local global i32, align 4
+
+define i32* @testTLS() {
+entry:
+ ret i32* @x
+}
More information about the llvm-commits
mailing list