Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions clang/lib/Basic/Targets/PPC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,13 +609,15 @@ bool PPCTargetInfo::initFeatureMap(
// Privileged instructions are off by default.
Features["privileged"] = false;

// The code generated by the -maix-small-local-[exec|dynamic]-tls option is
// turned off by default.
Features["aix-small-local-exec-tls"] = false;
Features["aix-small-local-dynamic-tls"] = false;
if (getTriple().isOSAIX()) {
Copy link
Contributor

@diggerlin diggerlin Mar 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if I understand correct, we do not need to set Features["aix-small-local-exec-tls"] = false; for AIX too, since we do not use the HasAIXSmallLocalExecTLS,HasAIXShLibTLSModelOpt,HasAIXSmallLocalDynamicTLS in the frontend .
and I also has upstream patch to remove all the unused variable which defined in the PPC.h #130994

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As seen from the proposed change to the test cases, listing here or not affects whether the IR lists the feature. The scope of this patch does not involve changing the behaviour on AIX (which may be controversial).

Any further desired changes for what features are listed for the IR still require further discussion. This patch makes a reasonable change against the status quo.

// The code generated by the -maix-small-local-[exec|dynamic]-tls option is
// turned off by default.
Features["aix-small-local-exec-tls"] = false;
Features["aix-small-local-dynamic-tls"] = false;

// Turn off TLS model opt by default.
Features["aix-shared-lib-tls-model-opt"] = false;
// Turn off TLS model opt by default.
Features["aix-shared-lib-tls-model-opt"] = false;
}

Features["spe"] = llvm::StringSwitch<bool>(CPU)
.Case("8548", true)
Expand Down
28 changes: 28 additions & 0 deletions clang/test/Driver/aix-shared-lib-tls-model-opt.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// RUN: %clang -target powerpc64-unknown-aix -S -emit-llvm %s -o - | FileCheck --check-prefixes=CHECK-AIX,CHECK-AIX-OFF %s
// RUN: %clang -target powerpc-unknown-aix -S -emit-llvm %s -o - | FileCheck --check-prefixes=CHECK-AIX,CHECK-AIX-OFF %s
// RUN: %clang -target powerpc64le-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-LINUX %s
// RUN: %clang -target powerpc64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-LINUX %s

// RUN: %clang -target powerpc64-unknown-aix -maix-shared-lib-tls-model-opt -S -emit-llvm \
// RUN: %s -o - | FileCheck %s --check-prefixes=CHECK-AIX,CHECK-AIX-ON

// FIXME: Clang driver diagnostic not implemented.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#130865 addresses this FIXME.

// RUN: true || not %clang -target powerpc-unknown-aix -maix-shared-lib-tls-model-opt \
// RUN: -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-UNSUPPORTED-TARGET %s
// RUN: true || not %clang -target powerpc64le-unknown-linux-gnu -maix-shared-lib-tls-model-opt \
// RUN: -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-UNSUPPORTED-TARGET %s
// RUN: true || not %clang -target powerpc64-unknown-linux-gnu -maix-shared-lib-tls-model-opt \
// RUN: -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-UNSUPPORTED-TARGET %s

int test(void) {
return 0;
}

// CHECK-AIX: test() #0 {
// CHECK-AIX: attributes #0 = {
// CHECK-AIX-OFF-SAME: -aix-shared-lib-tls-model-opt
// CHECK-AIX-ON-SAME: +aix-shared-lib-tls-model-opt

// CHECK-LINUX-NOT: {{[-+]aix-shared-lib-tls-model-opt}}

// CHECK-UNSUPPORTED-TARGET: option '-maix-shared-lib-tls-model-opt' cannot be specified on this target
15 changes: 8 additions & 7 deletions clang/test/Driver/aix-small-local-exec-dynamic-tls.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %clang -target powerpc64-unknown-aix -S -emit-llvm %s -o - | FileCheck %s
// RUN: %clang -target powerpc-unknown-aix -S -emit-llvm %s -o - | FileCheck %s
// RUN: %clang -target powerpc64le-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck %s
// RUN: %clang -target powerpc64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck %s
// RUN: %clang -target powerpc64-unknown-aix -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-AIX-DEFAULT %s
// RUN: %clang -target powerpc-unknown-aix -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-AIX-DEFAULT %s
// RUN: %clang -target powerpc64le-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-LINUX %s
// RUN: %clang -target powerpc64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-LINUX %s

// RUN: %clang -target powerpc64-unknown-aix -maix-small-local-exec-tls -S -emit-llvm \
// RUN: %s -o - | FileCheck %s --check-prefix=CHECK-AIX_SMALL_LOCALEXEC_TLS
Expand Down Expand Up @@ -39,9 +39,10 @@ int test(void) {
return 0;
}

// CHECK: test() #0 {
// CHECK: attributes #0 = {
// CHECK-SAME: {{-aix-small-local-exec-tls,.*-aix-small-local-dynamic-tls|-aix-small-local-dynamic-tls,.*-aix-small-local-exec-tls}}
// CHECK-AIX-DEFAULT: test() #0 {
// CHECK-AIX-DEFAULT: attributes #0 = {
// CHECK-AIX-DEFAULT-SAME: {{-aix-small-local-exec-tls,.*-aix-small-local-dynamic-tls|-aix-small-local-dynamic-tls,.*-aix-small-local-exec-tls}}
// CHECK-LINUX-NOT: {{[-+]aix-small-local-exec-tls,.*[-+]aix-small-local-dynamic-tls|[-+]aix-small-local-dynamic-tls,.*[-+]aix-small-local-exec-tls}}

// CHECK-UNSUPPORTED-AIX32: option '-maix-small-local-[exec|dynamic]-tls' cannot be specified on this target
// CHECK-UNSUPPORTED-LINUX: option '-maix-small-local-[exec|dynamic]-tls' cannot be specified on this target
Expand Down