Skip to content

Commit e0e80db

Browse files
[Clang codegen][PPC] Produce AIX-specific "target features" only for AIX (#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).
1 parent 998511c commit e0e80db

File tree

3 files changed

+44
-13
lines changed

3 files changed

+44
-13
lines changed

clang/lib/Basic/Targets/PPC.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -609,13 +609,15 @@ bool PPCTargetInfo::initFeatureMap(
609609
// Privileged instructions are off by default.
610610
Features["privileged"] = false;
611611

612-
// The code generated by the -maix-small-local-[exec|dynamic]-tls option is
613-
// turned off by default.
614-
Features["aix-small-local-exec-tls"] = false;
615-
Features["aix-small-local-dynamic-tls"] = false;
612+
if (getTriple().isOSAIX()) {
613+
// The code generated by the -maix-small-local-[exec|dynamic]-tls option is
614+
// turned off by default.
615+
Features["aix-small-local-exec-tls"] = false;
616+
Features["aix-small-local-dynamic-tls"] = false;
616617

617-
// Turn off TLS model opt by default.
618-
Features["aix-shared-lib-tls-model-opt"] = false;
618+
// Turn off TLS model opt by default.
619+
Features["aix-shared-lib-tls-model-opt"] = false;
620+
}
619621

620622
Features["spe"] = llvm::StringSwitch<bool>(CPU)
621623
.Case("8548", true)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// RUN: %clang -target powerpc64-unknown-aix -S -emit-llvm %s -o - | FileCheck --check-prefixes=CHECK-AIX,CHECK-AIX-OFF %s
2+
// RUN: %clang -target powerpc-unknown-aix -S -emit-llvm %s -o - | FileCheck --check-prefixes=CHECK-AIX,CHECK-AIX-OFF %s
3+
// RUN: %clang -target powerpc64le-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-LINUX %s
4+
// RUN: %clang -target powerpc64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-LINUX %s
5+
6+
// RUN: %clang -target powerpc64-unknown-aix -maix-shared-lib-tls-model-opt -S -emit-llvm \
7+
// RUN: %s -o - | FileCheck %s --check-prefixes=CHECK-AIX,CHECK-AIX-ON
8+
9+
// FIXME: Clang driver diagnostic not implemented.
10+
// RUN: true || not %clang -target powerpc-unknown-aix -maix-shared-lib-tls-model-opt \
11+
// RUN: -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-UNSUPPORTED-TARGET %s
12+
// RUN: true || not %clang -target powerpc64le-unknown-linux-gnu -maix-shared-lib-tls-model-opt \
13+
// RUN: -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-UNSUPPORTED-TARGET %s
14+
// RUN: true || not %clang -target powerpc64-unknown-linux-gnu -maix-shared-lib-tls-model-opt \
15+
// RUN: -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-UNSUPPORTED-TARGET %s
16+
17+
int test(void) {
18+
return 0;
19+
}
20+
21+
// CHECK-AIX: test() #0 {
22+
// CHECK-AIX: attributes #0 = {
23+
// CHECK-AIX-OFF-SAME: -aix-shared-lib-tls-model-opt
24+
// CHECK-AIX-ON-SAME: +aix-shared-lib-tls-model-opt
25+
26+
// CHECK-LINUX-NOT: {{[-+]aix-shared-lib-tls-model-opt}}
27+
28+
// CHECK-UNSUPPORTED-TARGET: option '-maix-shared-lib-tls-model-opt' cannot be specified on this target

clang/test/Driver/aix-small-local-exec-dynamic-tls.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// RUN: %clang -target powerpc64-unknown-aix -S -emit-llvm %s -o - | FileCheck %s
2-
// RUN: %clang -target powerpc-unknown-aix -S -emit-llvm %s -o - | FileCheck %s
3-
// RUN: %clang -target powerpc64le-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck %s
4-
// RUN: %clang -target powerpc64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck %s
1+
// RUN: %clang -target powerpc64-unknown-aix -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-AIX-DEFAULT %s
2+
// RUN: %clang -target powerpc-unknown-aix -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-AIX-DEFAULT %s
3+
// RUN: %clang -target powerpc64le-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-LINUX %s
4+
// RUN: %clang -target powerpc64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-LINUX %s
55

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

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

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

0 commit comments

Comments
 (0)