Skip to content

Commit 880f39a

Browse files
committed
[Clang] Enable AIX initial-exec TLS mode
Reviewed By: shchenz Differential Revision: https://reviews.llvm.org/D156076
1 parent 62790a8 commit 880f39a

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1877,7 +1877,7 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
18771877
if (Arg *A = Args.getLastArg(OPT_ftlsmodel_EQ)) {
18781878
if (T.isOSAIX()) {
18791879
StringRef Name = A->getValue();
1880-
if (Name != "global-dynamic" && Name != "local-exec")
1880+
if (Name == "local-dynamic")
18811881
Diags.Report(diag::err_aix_unsupported_tls_model) << Name;
18821882
}
18831883
}

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2054,7 +2054,7 @@ static void handleTLSModelAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
20542054
}
20552055

20562056
if (S.Context.getTargetInfo().getTriple().isOSAIX() &&
2057-
Model != "global-dynamic" && Model != "local-exec") {
2057+
Model == "local-dynamic") {
20582058
S.Diag(LiteralLoc, diag::err_aix_attr_unsupported_tls_model) << Model;
20592059
return;
20602060
}

clang/test/CodeGen/PowerPC/aix-tls-model.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// RUN: %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-GD
22
// RUN: %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 -ftls-model=global-dynamic -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-GD
33
// RUN: not %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 -ftls-model=local-dynamic -emit-llvm 2>&1 | FileCheck %s -check-prefix=CHECK-LD-ERROR
4-
// RUN: not %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 -ftls-model=initial-exec -emit-llvm 2>&1 | FileCheck %s -check-prefix=CHECK-IE-ERROR
4+
// RUN: %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 -ftls-model=initial-exec -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-IE
55
// RUN: %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 -ftls-model=local-exec -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-LE
66
// RUN: %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-GD
77
// RUN: %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 -ftls-model=global-dynamic -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-GD
88
// RUN: not %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 -ftls-model=local-dynamic -emit-llvm 2>&1 | FileCheck %s -check-prefix=CHECK-LD-ERROR
9-
// RUN: not %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 -ftls-model=initial-exec -emit-llvm 2>&1 | FileCheck %s -check-prefix=CHECK-IE-ERROR
9+
// RUN: %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 -ftls-model=initial-exec -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-IE
1010
// RUN: %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 -ftls-model=local-exec -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-LE
1111

1212
int z1 = 0;
@@ -22,7 +22,10 @@ int f() {
2222
// CHECK-GD: @x ={{.*}} thread_local global i32 0
2323
// CHECK-GD: @_ZZ1fvE1y = internal thread_local global i32 0
2424
// CHECK-LD-ERROR: error: TLS model 'local-dynamic' is not yet supported on AIX
25-
// CHECK-IE-ERROR: error: TLS model 'initial-exec' is not yet supported on AIX
25+
// CHECK-IE: @z1 ={{.*}} global i32 0
26+
// CHECK-IE: @z2 ={{.*}} global i32 0
27+
// CHECK-IE: @x ={{.*}} thread_local(initialexec) global i32 0
28+
// CHECK-IE: @_ZZ1fvE1y = internal thread_local(initialexec) global i32 0
2629
// CHECK-LE: @z1 ={{.*}} global i32 0
2730
// CHECK-LE: @z2 ={{.*}} global i32 0
2831
// CHECK-LE: @x ={{.*}} thread_local(localexec) global i32 0

clang/test/Sema/aix-attr-tls_model.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77

88
static __thread int y __attribute((tls_model("global-dynamic"))); // no-warning
99
static __thread int y __attribute((tls_model("local-dynamic"))); // expected-error {{TLS model 'local-dynamic' is not yet supported on AIX}}
10-
static __thread int y __attribute((tls_model("initial-exec"))); // expected-error {{TLS model 'initial-exec' is not yet supported on AIX}}
10+
static __thread int y __attribute((tls_model("initial-exec"))); // no-warning
1111
static __thread int y __attribute((tls_model("local-exec"))); // no-warning

0 commit comments

Comments
 (0)