[PATCH] D156203: [AIX][TLS] Add backend portion for the -maix-small-local-exec-tls option.

Amy Kwan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 24 22:17:34 PDT 2023


amyk created this revision.
amyk added reviewers: PowerPC, hubert.reinterpretcast, stefanp.
amyk added a project: LLVM.
Herald added subscribers: kbarton, hiraditya, nemanjai.
Herald added a project: All.
amyk requested review of this revision.
Herald added a subscriber: llvm-commits.

This patch adds the `llvm` (backend) portion of an AIX-specific option to inform
the compiler that it can use a faster access sequence for the local-exec TLS model
(formally named `aix-small-local-exec-tls`).

The clang portion of this option is in D155544 <https://reviews.llvm.org/D155544>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156203

Files:
  llvm/lib/Target/PowerPC/PPC.td
  llvm/lib/Target/PowerPC/PPCSubtarget.cpp
  llvm/test/CodeGen/PowerPC/check-aix-small-local-exec-tls-opt.ll


Index: llvm/test/CodeGen/PowerPC/check-aix-small-local-exec-tls-opt.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/check-aix-small-local-exec-tls-opt.ll
@@ -0,0 +1,23 @@
+; RUN: llc -mtriple powerpc64-ibm-aix-xcoff -mattr=+aix-small-local-exec-tls \
+; RUN:   -ppc-asm-full-reg-names < %s | FileCheck %s
+; RUN: not llc -mtriple powerpc-ibm-aix-xcoff -mattr=+aix-small-local-exec-tls \
+; RUN:   -ppc-asm-full-reg-names < %s 2>&1 | FileCheck %s --check-prefix=CHECK-NOT-SUPPORTED-AIX32
+; RUN: not llc -mtriple powerpc64le-unknown-linux-gnu -mattr=+aix-small-local-exec-tls \
+; RUN:   -ppc-asm-full-reg-names < %s 2>&1 | \
+; RUN:   FileCheck %s --check-prefix=CHECK-NOT-SUPPORTED
+
+define dso_local signext i32 @f() {
+entry:
+  ret i32 0
+}
+
+; Check that the -maix-small-local-exec-tls option is not supported on Linux.
+; CHECK-NOT-SUPPORTED: The aix-small-local-exec-tls attribute is only supported on AIX.
+
+; Check that the -maix-small-local-exec-tls option is not supported on AIX, 32-bit mode.
+; CHECK-NOT-SUPPORTED-AIX32: The aix-small-local-exec-tls attribute is currently only supported on AIX (64-bit mode).
+
+; Make sure that the test was actually compiled successfully after using the
+; -maix-small-local-exec-tls option.
+; CHECK:        li r3, 0
+; CHECK-NEXT:   blr
Index: llvm/lib/Target/PowerPC/PPCSubtarget.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+++ llvm/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -123,6 +123,17 @@
 
   // Determine endianness.
   IsLittleEndian = TM.isLittleEndian();
+
+  if (HasAIXSmallLocalExecTLS) {
+    if (!TargetTriple.isOSAIX())
+      report_fatal_error(
+        "The aix-small-local-exec-tls attribute is only supported on AIX.\n",
+        false);
+    if (!IsPPC64)
+      report_fatal_error(
+        "The aix-small-local-exec-tls attribute is currently only supported "
+        "on AIX (64-bit mode).\n", false);
+  }
 }
 
 bool PPCSubtarget::enableMachineScheduler() const { return true; }
Index: llvm/lib/Target/PowerPC/PPC.td
===================================================================
--- llvm/lib/Target/PowerPC/PPC.td
+++ llvm/lib/Target/PowerPC/PPC.td
@@ -318,6 +318,14 @@
   SubtargetFeature<"privileged", "HasPrivileged", "true",
                    "Add privileged instructions">;
 
+def FeatureAIXLocalExecTLS :
+  SubtargetFeature<"aix-small-local-exec-tls", "HasAIXSmallLocalExecTLS", "true",
+                   "Produce a faster access sequence for local-exec TLS "
+                   "variables where the offset from the TLS base "
+                   "is encoded as an immediate operand (AIX 64-bit only). "
+                   "This access sequence is not used for variables larger "
+                   "than 32KB.">;
+
 def FeaturePredictableSelectIsExpensive :
   SubtargetFeature<"predictable-select-expensive",
                    "PredictableSelectIsExpensive",


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156203.543819.patch
Type: text/x-patch
Size: 3001 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230725/4a49961a/attachment.bin>


More information about the llvm-commits mailing list