Author: abataev Date: Mon Jun 25 08:32:05 2018 New Revision: 335483 URL: http://llvm.org/viewvc/llvm-project?rev=335483&view=rev Log: [OPENMP] Do not consider address constant vars as possibly threadprivate.
Do not delay emission of the address constant variables in OpenMP mode as they cannot be defined as threadprivate. Added: cfe/trunk/test/OpenMP/constexpr_codegen.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=335483&r1=335482&r2=335483&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Jun 25 08:32:05 2018 @@ -1914,7 +1914,8 @@ bool CodeGenModule::MayBeEmittedEagerly( // If OpenMP is enabled and threadprivates must be generated like TLS, delay // codegen for global variables, because they may be marked as threadprivate. if (LangOpts.OpenMP && LangOpts.OpenMPUseTLS && - getContext().getTargetInfo().isTLSSupported() && isa<VarDecl>(Global)) + getContext().getTargetInfo().isTLSSupported() && isa<VarDecl>(Global) && + !isTypeConstant(Global->getType(), false)) return false; return true; Added: cfe/trunk/test/OpenMP/constexpr_codegen.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/constexpr_codegen.cpp?rev=335483&view=auto ============================================================================== --- cfe/trunk/test/OpenMP/constexpr_codegen.cpp (added) +++ cfe/trunk/test/OpenMP/constexpr_codegen.cpp Mon Jun 25 08:32:05 2018 @@ -0,0 +1,29 @@ +// RUN: %clang_cc1 -verify -fopenmp -std=c++11 -triple x86_64-unknown-unknown -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s +// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -debug-info-kind=limited -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s + +// RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 -triple x86_64-unknown-unknown -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY1 %s +// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -debug-info-kind=limited -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s +// SIMD-ONLY1-NOT: {{__kmpc|__tgt}} + +// expected-no-diagnostics +// +#ifndef HEADER +#define HEADER + +// CHECK: @{{.*}}Foo{{.*}}bar{{.*}} = constant i32 1, + +// Section A - Define a class with a static constexpr data member. +struct Foo { + static constexpr int bar = 1; +}; + +// Section B - ODR-use the data member. +void F(const int &); +void Test() { F(Foo::bar); } + +// Section C - Define the data member. +constexpr int Foo::bar; +#endif + _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits