diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2018-02-07 23:04:06 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2018-02-07 23:04:06 +0000 |
commit | 75e5736926bc03de96651e19ce0387924125cd18 (patch) | |
tree | 738fd81c45fe5e65877cb71f413025aad887d7fd | |
parent | 37765ff326cecbaa9aca87c40312749a6ef3c768 (diff) | |
download | bcm5719-llvm-75e5736926bc03de96651e19ce0387924125cd18.tar.gz bcm5719-llvm-75e5736926bc03de96651e19ce0387924125cd18.zip |
Don't try to use copy relocations with tls variables.
Should fix the lldb bot.
llvm-svn: 324539
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 7 | ||||
-rw-r--r-- | clang/test/CodeGen/dso-local-executable.c | 20 |
2 files changed, 24 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 7fa4fddc79e..9e42aa2750f 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -746,9 +746,10 @@ static bool shouldAssumeDSOLocal(const CodeGenModule &CGM, return false; // If we can use copy relocations we can assume it is local. - if (isa<VarDecl>(D) && - (RM == llvm::Reloc::Static || CGOpts.PIECopyRelocations)) - return true; + if (auto *VD = dyn_cast<VarDecl>(D)) + if (VD->getTLSKind() == VarDecl::TLS_None && + (RM == llvm::Reloc::Static || CGOpts.PIECopyRelocations)) + return true; // If we can use a plt entry as the symbol address we can assume it // is local. diff --git a/clang/test/CodeGen/dso-local-executable.c b/clang/test/CodeGen/dso-local-executable.c index 5637ae4127f..161ed51cd47 100644 --- a/clang/test/CodeGen/dso-local-executable.c +++ b/clang/test/CodeGen/dso-local-executable.c @@ -4,6 +4,8 @@ // STATIC-DAG: declare dso_local void @foo() // STATIC-DAG: @baz = dso_local global i32 42 // STATIC-DAG: define dso_local i32* @zed() +// STATIC-DAG: @thread_var = external thread_local global i32 +// STATIC-DAG: @local_thread_var = dso_local thread_local global i32 42 // RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm -pic-is-pie -mpie-copy-relocations %s -o - | FileCheck --check-prefix=PIE-COPY %s // PIE-COPY-DAG: @bar = external dso_local global i32 @@ -11,6 +13,8 @@ // PIE-COPY-DAG: declare void @foo() // PIE-COPY-DAG: @baz = dso_local global i32 42 // PIE-COPY-DAG: define dso_local i32* @zed() +// PIE-COPY-DAG: @thread_var = external thread_local global i32 +// PIE-COPY-DAG: @local_thread_var = dso_local thread_local global i32 42 // RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm -pic-is-pie %s -o - | FileCheck --check-prefix=PIE %s // PIE-DAG: @bar = external global i32 @@ -18,6 +22,8 @@ // PIE-DAG: declare void @foo() // PIE-DAG: @baz = dso_local global i32 42 // PIE-DAG: define dso_local i32* @zed() +// PIE-DAG: @thread_var = external thread_local global i32 +// PIE-DAG: @local_thread_var = dso_local thread_local global i32 42 // RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm -mrelocation-model static -fno-plt %s -o - | FileCheck --check-prefix=NOPLT %s // NOPLT-DAG: @bar = external dso_local global i32 @@ -25,6 +31,8 @@ // NOPLT-DAG: declare void @foo() // NOPLT-DAG: @baz = dso_local global i32 42 // NOPLT-DAG: define dso_local i32* @zed() +// NOPLT-DAG: @thread_var = external thread_local global i32 +// NOPLT-DAG: @local_thread_var = dso_local thread_local global i32 42 // RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm -fno-plt -pic-is-pie -mpie-copy-relocations %s -o - | FileCheck --check-prefix=PIE-COPY-NOPLT %s // PIE-COPY-NOPLT-DAG: @bar = external dso_local global i32 @@ -32,6 +40,8 @@ // PIE-COPY-NOPLT-DAG: declare void @foo() // PIE-COPY-NOPLT-DAG: @baz = dso_local global i32 42 // PIE-COPY-NOPLT-DAG: define dso_local i32* @zed() +// PIE-COPY-NOPLT-DAG: @thread_var = external thread_local global i32 +// PIE-COPY-NOPLT-DAG: @local_thread_var = dso_local thread_local global i32 42 // RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm -pic-is-pie -fno-plt %s -o - | FileCheck --check-prefix=PIE-NO-PLT %s // RUN: %clang_cc1 -triple powerpc64le-pc-linux -emit-llvm -mrelocation-model static %s -o - | FileCheck --check-prefix=PIE-NO-PLT %s @@ -40,6 +50,8 @@ // PIE-NO-PLT-DAG: declare void @foo() // PIE-NO-PLT-DAG: @baz = dso_local global i32 42 // PIE-NO-PLT-DAG: define dso_local i32* @zed() +// PIE-NO-PLT-DAG: @thread_var = external thread_local global i32 +// PIE-NO-PLT-DAG: @local_thread_var = dso_local thread_local global i32 42 // RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm %s -o - | FileCheck --check-prefix=SHARED %s // SHARED-DAG: @bar = external global i32 @@ -47,6 +59,8 @@ // SHARED-DAG: declare void @foo() // SHARED-DAG: @baz = global i32 42 // SHARED-DAG: define i32* @zed() +// SHARED-DAG: @thread_var = external thread_local global i32 +// SHARED-DAG: @local_thread_var = thread_local global i32 42 extern int bar; __attribute__((weak)) extern int weak_bar; @@ -57,3 +71,9 @@ int *zed() { foo(); return baz ? &weak_bar : &bar; } + +extern __thread int thread_var; +__thread int local_thread_var = 42; +int *get_thread_var(int a) { + return a ? &thread_var : &local_thread_var; +} |