-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Clang codegen][PPC] Produce AIX-specific "target features" only for AIX #130864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Clang codegen][PPC] Produce AIX-specific "target features" only for AIX #130864
Conversation
@llvm/pr-subscribers-clang-driver @llvm/pr-subscribers-clang-codegen Author: Hubert Tong (hubert-reinterpretcast) ChangesListing AIX-specific "target features" in the IR are a source of Full diff: https://github.com/llvm/llvm-project/pull/130864.diff 3 Files Affected:
diff --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 2d8891a739ca3..facf095d7fcf1 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -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()) {
+ // 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)
diff --git a/clang/test/Driver/aix-shared-lib-tls-model-opt.c b/clang/test/Driver/aix-shared-lib-tls-model-opt.c
new file mode 100644
index 0000000000000..e610bb6d15d9d
--- /dev/null
+++ b/clang/test/Driver/aix-shared-lib-tls-model-opt.c
@@ -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.
+// 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
diff --git a/clang/test/Driver/aix-small-local-exec-dynamic-tls.c b/clang/test/Driver/aix-small-local-exec-dynamic-tls.c
index e8ee07bff35f5..1a0619b58e891 100644
--- a/clang/test/Driver/aix-small-local-exec-dynamic-tls.c
+++ b/clang/test/Driver/aix-small-local-exec-dynamic-tls.c
@@ -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
@@ -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
|
// 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#130865 addresses this FIXME.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
// turned off by default. | ||
Features["aix-small-local-exec-tls"] = false; | ||
Features["aix-small-local-dynamic-tls"] = false; | ||
if (getTriple().isOSAIX()) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
…AIX (llvm#130864) Listing AIX-specific "target features" in the IR are a source of confusion on PPC Linux. Generate them only for AIX (at least by default).
Listing AIX-specific "target features" in the IR are a source of
confusion on PPC Linux. Generate them only for AIX (at least by
default).