Skip to content

Commit 8bdbee8

Browse files
committed
[AIX][TLS] Add target attribute for -maix-small-local-exec-tls option.
This patch adds a target attribute for an AIX-specific option that informs 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. The initial implementation to generate the faster access sequence is in D155600. Differential Revision: https://reviews.llvm.org/D156203
1 parent 7e31b45 commit 8bdbee8

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed

llvm/lib/Target/PowerPC/PPC.td

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,17 @@ def FeaturePrivileged :
318318
SubtargetFeature<"privileged", "HasPrivileged", "true",
319319
"Add privileged instructions">;
320320

321+
// Specifies that local-exec TLS accesses in any function with this target
322+
// attribute should use the optimized TOC-free sequence (where the offset is an
323+
// immediate off of R13 for which the linker might add fix-up code if the
324+
// immediate is too large).
325+
// Clearly, this isn't really a feature of the subtarget, but is used as a
326+
// convenient way to affect code generation for individual functions.
327+
def FeatureAIXLocalExecTLS :
328+
SubtargetFeature<"aix-small-local-exec-tls", "HasAIXSmallLocalExecTLS", "true",
329+
"Produce a TOC-free local-exec TLS sequence for this function "
330+
"for 64-bit AIX">;
331+
321332
def FeaturePredictableSelectIsExpensive :
322333
SubtargetFeature<"predictable-select-expensive",
323334
"PredictableSelectIsExpensive",

llvm/lib/Target/PowerPC/PPCSubtarget.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ void PPCSubtarget::initSubtargetFeatures(StringRef CPU, StringRef TuneCPU,
123123

124124
// Determine endianness.
125125
IsLittleEndian = TM.isLittleEndian();
126+
127+
if (HasAIXSmallLocalExecTLS && (!TargetTriple.isOSAIX() || !IsPPC64))
128+
report_fatal_error(
129+
"The aix-small-local-exec-tls attribute is only supported on AIX in "
130+
"64-bit mode.\n", false);
126131
}
127132

128133
bool PPCSubtarget::enableMachineScheduler() const { return true; }
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
; RUN: llc -mtriple powerpc64-ibm-aix-xcoff -ppc-asm-full-reg-names \
2+
; RUN: < %s | FileCheck %s
3+
; RUN: not llc -mtriple powerpc-ibm-aix-xcoff -ppc-asm-full-reg-names \
4+
; RUN: < %s 2>&1 | FileCheck %s --check-prefix=CHECK-NOT-SUPPORTED
5+
; RUN: not llc -mtriple powerpc64le-unknown-linux-gnu -ppc-asm-full-reg-names \
6+
; RUN: < %s 2>&1 | FileCheck %s --check-prefix=CHECK-NOT-SUPPORTED
7+
8+
define dso_local signext i32 @testWithIRAttr() #0 {
9+
entry:
10+
ret i32 0
11+
}
12+
; Check that the aix-small-local-exec-tls attribute is not supported on Linux and AIX (32-bit).
13+
; CHECK-NOT-SUPPORTED: The aix-small-local-exec-tls attribute is only supported on AIX in 64-bit mode.
14+
15+
; Make sure that the test was actually compiled successfully after using the
16+
; aix-small-local-exec-tls attribute.
17+
; CHECK-LABEL: testWithIRAttr:
18+
; CHECK: li r3, 0
19+
; CHECK-NEXT: blr
20+
21+
22+
attributes #0 = { "target-features"="+aix-small-local-exec-tls" }
23+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
; RUN: llc -mtriple powerpc64-ibm-aix-xcoff -mattr=+aix-small-local-exec-tls \
2+
; RUN: -ppc-asm-full-reg-names < %s | FileCheck %s
3+
; RUN: not llc -mtriple powerpc-ibm-aix-xcoff -mattr=+aix-small-local-exec-tls \
4+
; RUN: -ppc-asm-full-reg-names < %s 2>&1 | \
5+
; RUN: FileCheck %s --check-prefix=CHECK-NOT-SUPPORTED
6+
; RUN: not llc -mtriple powerpc64le-unknown-linux-gnu -mattr=+aix-small-local-exec-tls \
7+
; RUN: -ppc-asm-full-reg-names < %s 2>&1 | \
8+
; RUN: FileCheck %s --check-prefix=CHECK-NOT-SUPPORTED
9+
10+
define dso_local signext i32 @testNoIRAttr() {
11+
entry:
12+
ret i32 0
13+
}
14+
15+
; Check that the aix-small-local-exec-tls attribute is not supported on Linux and AIX (32-bit).
16+
; CHECK-NOT-SUPPORTED: The aix-small-local-exec-tls attribute is only supported on AIX in 64-bit mode.
17+
18+
; Make sure that the test was actually compiled successfully after using the
19+
; aix-small-local-exec-tls attribute.
20+
; CHECK-LABEL: testNoIRAttr:
21+
; CHECK: li r3, 0
22+
; CHECK-NEXT: blr

0 commit comments

Comments
 (0)