[PATCH] D85448: [PowerPC][PCRelative] Set TLS unsupported with PC relative memops
Kamau Bridgeman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 6 10:32:53 PDT 2020
kamaub created this revision.
kamaub added reviewers: PowerPC, stefanp, nemanjai, NeHuang.
Herald added subscribers: llvm-commits, shchenz, kbarton, hiraditya.
Herald added a project: LLVM.
kamaub requested review of this revision.
Herald added a subscriber: wuzish.
Instroduce 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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D85448
Files:
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/test/CodeGen/PowerPC/pcrel-tls.ll
Index: llvm/test/CodeGen/PowerPC/pcrel-tls.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/pcrel-tls.ll
@@ -0,0 +1,20 @@
+; 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: not --crash llc -mcpu=pwr10 -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN: -verify-machineinstrs -mattr=+pcrelative-memops -enable-ppc-pcrel-tls \
+; RUN: -o - < %s 2>&1 | FileCheck %s --check-prefix=CHECK-PCREL-TLS
+; 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-PCREL-TLS: TOC pointer used in a function using PC-Relative addressing!
+; CHECK-NOPCREL: blr
+
+ at x = external thread_local global i32, align 4
+
+define i32* @testTLS() {
+entry:
+ ret i32* @x
+}
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -121,6 +121,11 @@
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");
@@ -2901,6 +2906,10 @@
// 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())
+ assert(EnablePPCPCRelTLS &&
+ "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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85448.283650.patch
Type: text/x-patch
Size: 2385 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200806/8b4075d4/attachment.bin>
More information about the llvm-commits
mailing list