diff options
author | Manman Ren <manman.ren@gmail.com> | 2015-11-11 19:19:26 +0000 |
---|---|---|
committer | Manman Ren <manman.ren@gmail.com> | 2015-11-11 19:19:26 +0000 |
commit | 14f88158c7a566deb37ff1104fda5928103cc0e4 (patch) | |
tree | 278ca05a6e876ed66933941a9dd2442bd7509bd6 | |
parent | fc4e1c74abfae40c9288cdbc03506e14dbe03850 (diff) | |
download | bcm5719-llvm-14f88158c7a566deb37ff1104fda5928103cc0e4.tar.gz bcm5719-llvm-14f88158c7a566deb37ff1104fda5928103cc0e4.zip |
[TLS] move setting tls_guard in tls_init.
We used to emit the store prior to branch in the entry block. To make it more
efficient, this commit moves it to the init block. We still mark as initialized
before initializing anything else.
llvm-svn: 252777
-rw-r--r-- | clang/lib/CodeGen/CGDeclCXX.cpp | 8 | ||||
-rw-r--r-- | clang/test/CodeGenCXX/cxx11-thread-local.cpp | 2 | ||||
-rw-r--r-- | clang/test/OpenMP/threadprivate_codegen.cpp | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index e74467bb141..df75045c789 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -518,14 +518,14 @@ CodeGenFunction::GenerateCXXGlobalInitFunc(llvm::Function *Fn, llvm::Value *GuardVal = Builder.CreateLoad(Guard); llvm::Value *Uninit = Builder.CreateIsNull(GuardVal, "guard.uninitialized"); - // Mark as initialized before initializing anything else. If the - // initializers use previously-initialized thread_local vars, that's - // probably supposed to be OK, but the standard doesn't say. - Builder.CreateStore(llvm::ConstantInt::get(GuardVal->getType(),1), Guard); llvm::BasicBlock *InitBlock = createBasicBlock("init"); ExitBlock = createBasicBlock("exit"); Builder.CreateCondBr(Uninit, InitBlock, ExitBlock); EmitBlock(InitBlock); + // Mark as initialized before initializing anything else. If the + // initializers use previously-initialized thread_local vars, that's + // probably supposed to be OK, but the standard doesn't say. + Builder.CreateStore(llvm::ConstantInt::get(GuardVal->getType(),1), Guard); } RunCleanupsScope Scope(*this); diff --git a/clang/test/CodeGenCXX/cxx11-thread-local.cpp b/clang/test/CodeGenCXX/cxx11-thread-local.cpp index e28447e01eb..9d9d255dcb0 100644 --- a/clang/test/CodeGenCXX/cxx11-thread-local.cpp +++ b/clang/test/CodeGenCXX/cxx11-thread-local.cpp @@ -173,9 +173,9 @@ void set_anon_i() { // CHECK: define {{.*}}@__tls_init() // CHECK: load i8, i8* @__tls_guard // CHECK: %[[NEED_TLS_INIT:.*]] = icmp eq i8 %{{.*}}, 0 -// CHECK: store i8 1, i8* @__tls_guard // CHECK: br i1 %[[NEED_TLS_INIT]], // init: +// CHECK: store i8 1, i8* @__tls_guard // CHECK: call void @[[A_INIT]]() // CHECK: call void @[[D_INIT]]() // CHECK: call void @[[U_M_INIT]]() diff --git a/clang/test/OpenMP/threadprivate_codegen.cpp b/clang/test/OpenMP/threadprivate_codegen.cpp index 97678b4b666..53d7ef70838 100644 --- a/clang/test/OpenMP/threadprivate_codegen.cpp +++ b/clang/test/OpenMP/threadprivate_codegen.cpp @@ -939,9 +939,9 @@ int foobar() { // CHECK-TLS: define internal void @__tls_init() // CHECK-TLS: [[GRD:%.*]] = load i8, i8* @__tls_guard // CHECK-TLS-NEXT: [[IS_INIT:%.*]] = icmp eq i8 [[GRD]], 0 -// CHECK-TLS-NEXT: store i8 1, i8* @__tls_guard // CHECK-TLS-NEXT: br i1 [[IS_INIT]], label %[[INIT_LABEL:[^,]+]], label %[[DONE_LABEL:[^,]+]]{{.*}} // CHECK-TLS: [[INIT_LABEL]] +// CHECK-TLS-NEXT: store i8 1, i8* @__tls_guard // CHECK-TLS: call void [[GS1_CXX_INIT]] // CHECK-TLS-NOT: call void [[GS2_CXX_INIT]] // CHECK-TLS: call void [[ARR_X_CXX_INIT]] |