diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -978,20 +978,14 @@ if (TT.isOSBinFormatCOFF() || (TT.isOSWindows() && TT.isOSBinFormatMachO())) return true; - const auto &CGOpts = CGM.getCodeGenOpts(); - llvm::Reloc::Model RM = CGOpts.RelocationModel; - const auto &LOpts = CGM.getLangOpts(); - - if (TT.isOSBinFormatMachO()) { - if (RM == llvm::Reloc::Static) - return true; - return GV->isStrongDefinitionForLinker(); - } - // Only handle COFF and ELF for now. if (!TT.isOSBinFormatELF()) return false; + // If this is not an executable, don't assume anything is local. + const auto &CGOpts = CGM.getCodeGenOpts(); + llvm::Reloc::Model RM = CGOpts.RelocationModel; + const auto &LOpts = CGM.getLangOpts(); if (RM != llvm::Reloc::Static && !LOpts.PIE) { // On ELF, if -fno-semantic-interposition is specified and the target // supports local aliases, there will be neither CC1 diff --git a/clang/test/CodeGen/attr-weak-import.c b/clang/test/CodeGen/attr-weak-import.c --- a/clang/test/CodeGen/attr-weak-import.c +++ b/clang/test/CodeGen/attr-weak-import.c @@ -18,9 +18,9 @@ int E; extern int E __attribute__((weak_import)); -// CHECK: @A = dso_local global i32 +// CHECK: @A = global i32 // CHECK-NOT: @B = -// CHECK: @C = dso_local global i32 -// CHECK: @D = dso_local global i32 -// CHECK: @E = dso_local global i32 +// CHECK: @C = global i32 +// CHECK: @D = global i32 +// CHECK: @E = global i32 diff --git a/clang/test/CodeGenCXX/bitfield-layout.cpp b/clang/test/CodeGenCXX/bitfield-layout.cpp --- a/clang/test/CodeGenCXX/bitfield-layout.cpp +++ b/clang/test/CodeGenCXX/bitfield-layout.cpp @@ -93,7 +93,7 @@ } const U = {15}; // 0b00001111 return U.i; } -// CHECK: define dso_local i32 @test_trunc_int() +// CHECK: define{{.*}} i32 @test_trunc_int() // CHECK: ret i32 -1 int test_trunc_three_bits() { @@ -102,7 +102,7 @@ } const U = {15}; // 0b00001111 return U.i; } -// CHECK: define dso_local i32 @test_trunc_three_bits() +// CHECK: define{{.*}} i32 @test_trunc_three_bits() // CHECK: ret i32 -1 int test_trunc_1() { @@ -111,7 +111,7 @@ } const U = {15}; // 0b00001111 return U.i; } -// CHECK: define dso_local i32 @test_trunc_1() +// CHECK: define{{.*}} i32 @test_trunc_1() // CHECK: ret i32 -1 int test_trunc_zero() { @@ -120,7 +120,7 @@ } const U = {80}; // 0b01010000 return U.i; } -// CHECK: define dso_local i32 @test_trunc_zero() +// CHECK: define{{.*}} i32 @test_trunc_zero() // CHECK: ret i32 0 int test_constexpr() { @@ -129,7 +129,7 @@ } const U = {1 + 2 + 4 + 8}; // 0b00001111 return U.i; } -// CHECK: define dso_local i32 @test_constexpr() +// CHECK: define{{.*}} i32 @test_constexpr() // CHECK: ret i32 -1 int test_notrunc() { @@ -138,7 +138,7 @@ } const U = {1 + 2 + 4 + 8}; // 0b00001111 return U.i; } -// CHECK: define dso_local i32 @test_notrunc() +// CHECK: define{{.*}} i32 @test_notrunc() // CHECK: ret i32 15 long long test_trunc_long_long() { @@ -147,6 +147,6 @@ } const U = {0b0100111101001101}; return U.i; } -// CHECK: define dso_local i64 @test_trunc_long_long() +// CHECK: define{{.*}} i64 @test_trunc_long_long() // CHECK: ret i64 3917 } diff --git a/clang/test/CodeGenCXX/const-init.cpp b/clang/test/CodeGenCXX/const-init.cpp --- a/clang/test/CodeGenCXX/const-init.cpp +++ b/clang/test/CodeGenCXX/const-init.cpp @@ -2,17 +2,17 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -std=c++98 -o - %s | FileCheck %s // RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -std=c++11 -o - %s | FileCheck %s -// CHECK: @a = dso_local global i32 10 +// CHECK: @a = global i32 10 int a = 10; -// CHECK: @ar = dso_local constant i32* @a +// CHECK: @ar = constant i32* @a int &ar = a; void f(); -// CHECK: @fr = dso_local constant void ()* @_Z1fv +// CHECK: @fr = constant void ()* @_Z1fv void (&fr)() = f; struct S { int& a; }; -// CHECK: @s = dso_local global %struct.S { i32* @a } +// CHECK: @s = global %struct.S { i32* @a } S s = { a }; // PR5581 @@ -23,7 +23,7 @@ unsigned f; }; -// CHECK: @_ZN6PR55812g0E = dso_local global %"class.PR5581::C" { i32 1 } +// CHECK: @_ZN6PR55812g0E = global %"class.PR5581::C" { i32 1 } C g0 = { C::e1 }; } @@ -39,10 +39,10 @@ static int g(); } a; - // CHECK: @_ZN5test22t0E = dso_local global double {{1\.0+e\+0+}}, align 8 - // CHECK: @_ZN5test22t1E = dso_local global [2 x double] [double {{1\.0+e\+0+}}, double {{5\.0+e-0*}}1], align 16 - // CHECK: @_ZN5test22t2E = dso_local global double* @_ZN5test21A1d - // CHECK: @_ZN5test22t3E = dso_local global {{.*}} @_ZN5test21A1g + // CHECK: @_ZN5test22t0E = global double {{1\.0+e\+0+}}, align 8 + // CHECK: @_ZN5test22t1E = global [2 x double] [double {{1\.0+e\+0+}}, double {{5\.0+e-0*}}1], align 16 + // CHECK: @_ZN5test22t2E = global double* @_ZN5test21A1d + // CHECK: @_ZN5test22t3E = global {{.*}} @_ZN5test21A1g double t0 = A::d; double t1[] = { A::d, A::f }; const double *t2 = &a.d; @@ -50,7 +50,7 @@ } // We don't expect to fold this in the frontend, but make sure it doesn't crash. -// CHECK: @PR9558 = dso_local global float 0.000000e+0 +// CHECK: @PR9558 = global float 0.000000e+0 float PR9558 = reinterpret_cast("asd"); // An initialized const automatic variable cannot be promoted to a constant @@ -66,7 +66,7 @@ // Make sure we don't try to fold this in the frontend; the backend can't // handle it. -// CHECK: @PR11705 = dso_local global i128 0 +// CHECK: @PR11705 = global i128 0 __int128_t PR11705 = (__int128_t)&PR11705; // Make sure we don't try to fold this either. @@ -77,11 +77,11 @@ // CHECK: @_ZZ21FoldableAddrLabelDiffvE1x = internal global i64 sub (i64 ptrtoint (i8* blockaddress(@_Z21FoldableAddrLabelDiffv void FoldableAddrLabelDiff() { static long x = (long)&&a-(long)&&b; a:b:return;} -// CHECK: @i = dso_local constant i32* bitcast (float* @PR9558 to i32*) +// CHECK: @i = constant i32* bitcast (float* @PR9558 to i32*) int &i = reinterpret_cast(PR9558); int arr[2]; -// CHECK: @pastEnd = dso_local constant i32* bitcast (i8* getelementptr (i8, i8* bitcast ([2 x i32]* @arr to i8*), i64 8) to i32*) +// CHECK: @pastEnd = constant i32* bitcast (i8* getelementptr (i8, i8* bitcast ([2 x i32]* @arr to i8*), i64 8) to i32*) int &pastEnd = arr[2]; struct X { diff --git a/clang/test/CodeGenCXX/linkage.cpp b/clang/test/CodeGenCXX/linkage.cpp --- a/clang/test/CodeGenCXX/linkage.cpp +++ b/clang/test/CodeGenCXX/linkage.cpp @@ -226,5 +226,5 @@ template class> struct A {}; struct B { template struct C; }; void f(A) {} - // CHECK-DAG: define dso_local void @_ZN6test181fENS_1AINS_1B1CEEE( + // CHECK-DAG: define void @_ZN6test181fENS_1AINS_1B1CEEE( } diff --git a/clang/test/CodeGenCXX/temporaries.cpp b/clang/test/CodeGenCXX/temporaries.cpp --- a/clang/test/CodeGenCXX/temporaries.cpp +++ b/clang/test/CodeGenCXX/temporaries.cpp @@ -60,7 +60,7 @@ }; // CHECK: @_ZGRN16RefTempSubobject2srE_ = internal global { i32*, [3 x i32] } { {{.*}} getelementptr {{.*}} @_ZGRN16RefTempSubobject2srE_ {{.*}}, [3 x i32] [i32 1, i32 2, i32 3] } - // CHECK: @_ZN16RefTempSubobject2srE = {{.*}} constant {{.*}} @_ZGRN16RefTempSubobject2srE_ + // CHECK: @_ZN16RefTempSubobject2srE = constant {{.*}} @_ZGRN16RefTempSubobject2srE_ constexpr const SelfReferential &sr = SelfReferential(); } diff --git a/clang/test/CodeGenCXX/type_visibility.cpp b/clang/test/CodeGenCXX/type_visibility.cpp --- a/clang/test/CodeGenCXX/type_visibility.cpp +++ b/clang/test/CodeGenCXX/type_visibility.cpp @@ -110,14 +110,14 @@ }; void A::foo() {} - // FUNS-LABEL: define{{.*}} void @_ZN5type01A3fooEv( - // VARS: @_ZTVN5type01AE = dso_local unnamed_addr constant - // VARS: @_ZTSN5type01AE = dso_local constant - // VARS: @_ZTIN5type01AE = dso_local constant + // FUNS-LABEL: define void @_ZN5type01A3fooEv( + // VARS: @_ZTVN5type01AE = unnamed_addr constant + // VARS: @_ZTSN5type01AE = constant + // VARS: @_ZTIN5type01AE = constant // FUNS-HIDDEN-LABEL: define hidden void @_ZN5type01A3fooEv( - // VARS-HIDDEN: @_ZTVN5type01AE = dso_local unnamed_addr constant - // VARS-HIDDEN: @_ZTSN5type01AE = dso_local constant - // VARS-HIDDEN: @_ZTIN5type01AE = dso_local constant + // VARS-HIDDEN: @_ZTVN5type01AE = unnamed_addr constant + // VARS-HIDDEN: @_ZTSN5type01AE = constant + // VARS-HIDDEN: @_ZTIN5type01AE = constant } namespace type1 { @@ -127,13 +127,13 @@ void A::foo() {} // FUNS-LABEL: define hidden void @_ZN5type11A3fooEv( - // VARS: @_ZTVN5type11AE = dso_local unnamed_addr constant - // VARS: @_ZTSN5type11AE = dso_local constant - // VARS: @_ZTIN5type11AE = dso_local constant + // VARS: @_ZTVN5type11AE = unnamed_addr constant + // VARS: @_ZTSN5type11AE = constant + // VARS: @_ZTIN5type11AE = constant // FUNS-HIDDEN-LABEL: define hidden void @_ZN5type11A3fooEv( - // VARS-HIDDEN: @_ZTVN5type11AE = dso_local unnamed_addr constant - // VARS-HIDDEN: @_ZTSN5type11AE = dso_local constant - // VARS-HIDDEN: @_ZTIN5type11AE = dso_local constant + // VARS-HIDDEN: @_ZTVN5type11AE = unnamed_addr constant + // VARS-HIDDEN: @_ZTSN5type11AE = constant + // VARS-HIDDEN: @_ZTIN5type11AE = constant } namespace type2 { @@ -142,7 +142,7 @@ }; void A::foo() {} - // FUNS-LABEL: define dso_local void @_ZN5type21A3fooEv( + // FUNS-LABEL: define void @_ZN5type21A3fooEv( // VARS: @_ZTVN5type21AE = hidden unnamed_addr constant // VARS: @_ZTSN5type21AE = hidden constant // VARS: @_ZTIN5type21AE = hidden constant @@ -158,11 +158,11 @@ }; void A::foo() {} - // FUNS-LABEL: define dso_local void @_ZN5type31A3fooEv( + // FUNS-LABEL: define void @_ZN5type31A3fooEv( // VARS: @_ZTVN5type31AE = hidden unnamed_addr constant // VARS: @_ZTSN5type31AE = hidden constant // VARS: @_ZTIN5type31AE = hidden constant - // FUNS-HIDDEN-LABEL: define dso_local void @_ZN5type31A3fooEv( + // FUNS-HIDDEN-LABEL: define void @_ZN5type31A3fooEv( // VARS-HIDDEN: @_ZTVN5type31AE = hidden unnamed_addr constant // VARS-HIDDEN: @_ZTSN5type31AE = hidden constant // VARS-HIDDEN: @_ZTIN5type31AE = hidden constant diff --git a/clang/test/CodeGenCXX/visibility.cpp b/clang/test/CodeGenCXX/visibility.cpp --- a/clang/test/CodeGenCXX/visibility.cpp +++ b/clang/test/CodeGenCXX/visibility.cpp @@ -18,7 +18,7 @@ }; H DEFAULT a; X<&a> b; - // CHECK: _ZN6test301bE = dso_local global + // CHECK: _ZN6test301bE = global // CHECK-HIDDEN: _ZN6test301bE = hidden global } @@ -33,7 +33,7 @@ class DEFAULT A { }; X::definition a; - // CHECK: @_ZN6test251aE = dso_local global + // CHECK: @_ZN6test251aE = global // CHECK-HIDDEN: @_ZN6test251aE = hidden global } @@ -41,7 +41,7 @@ class DEFAULT foo { }; foo myvec; - // CHECK: @_ZN6test285myvecE = dso_local global + // CHECK: @_ZN6test285myvecE = global // CHECK-HIDDEN: @_ZN6test285myvecE = hidden global } @@ -53,8 +53,8 @@ DEFAULT extern RECT data_rect; RECT data_rect = { -1}; #pragma GCC visibility pop - // CHECK: @_ZN6test299data_rectE = dso_local global - // CHECK-HIDDEN: @_ZN6test299data_rectE = dso_local global + // CHECK: @_ZN6test299data_rectE = global + // CHECK-HIDDEN: @_ZN6test299data_rectE = global } namespace test40 { @@ -103,17 +103,17 @@ // CHECK: @_ZN5Test425VariableInHiddenNamespaceE = hidden global i32 10 // CHECK: @_ZN5Test71aE = hidden global -// CHECK: @_ZN5Test71bE = dso_local global -// CHECK: @test9_var = dso_local global -// CHECK-HIDDEN: @test9_var = dso_local global +// CHECK: @_ZN5Test71bE = global +// CHECK: @test9_var = global +// CHECK-HIDDEN: @test9_var = global // CHECK: @_ZN6Test121A6hiddenE = external hidden global // CHECK: @_ZN6Test121A7visibleE = external global // CHECK-HIDDEN: @_ZN6Test121A6hiddenE = external hidden global // CHECK-HIDDEN: @_ZN6Test121A7visibleE = external global // CHECK: @_ZN6Test131B1aE = hidden global -// CHECK: @_ZN6Test131C1aE = dso_local global +// CHECK: @_ZN6Test131C1aE = global // CHECK-HIDDEN: @_ZN6Test131B1aE = hidden global -// CHECK-HIDDEN: @_ZN6Test131C1aE = dso_local global +// CHECK-HIDDEN: @_ZN6Test131C1aE = global // CHECK: @_ZN6Test143varE = external global // CHECK-HIDDEN: @_ZN6Test143varE = external global // CHECK: @_ZN6Test154TempINS_1AEE5Inner6bufferE = external global [0 x i8] @@ -134,8 +134,8 @@ void C::D::g() { } - // CHECK: _ZTVN6test271CIiE1DE = dso_local unnamed_addr constant - // CHECK-HIDDEN: _ZTVN6test271CIiE1DE = dso_local unnamed_addr constant + // CHECK: _ZTVN6test271CIiE1DE = unnamed_addr constant + // CHECK-HIDDEN: _ZTVN6test271CIiE1DE = unnamed_addr constant } // CHECK: @_ZTVN5Test63fooE = linkonce_odr hidden unnamed_addr constant @@ -195,7 +195,7 @@ }; // A has default visibility. - // CHECK-LABEL: define dso_local void @_ZN5Test41A1fEv + // CHECK-LABEL: define void @_ZN5Test41A1fEv void A::f() { } } @@ -209,7 +209,7 @@ namespace NS { // g is in NS, but this NS decl is not hidden. - // CHECK-LABEL: define dso_local void @_ZN5Test52NS1gEv + // CHECK-LABEL: define void @_ZN5Test52NS1gEv void g() { } } } @@ -268,8 +268,8 @@ void DEFAULT test9_fun(struct A *a) { } struct A DEFAULT test9_var; // above } - // CHECK-LABEL: define dso_local void @test9_fun( - // CHECK-HIDDEN-LABEL: define dso_local void @test9_fun( + // CHECK-LABEL: define void @test9_fun( + // CHECK-HIDDEN-LABEL: define void @test9_fun( void test() { A a = test9_var; @@ -285,8 +285,8 @@ void foo(A*); }; - // CHECK-LABEL: define dso_local void @_ZN6Test101B3fooEPNS_1AE( - // CHECK-HIDDEN-LABEL: define dso_local void @_ZN6Test101B3fooEPNS_1AE( + // CHECK-LABEL: define void @_ZN6Test101B3fooEPNS_1AE( + // CHECK-HIDDEN-LABEL: define void @_ZN6Test101B3fooEPNS_1AE( void B::foo(A*) {} } @@ -507,7 +507,7 @@ static void test3(); }; - // CHECK-LABEL: define dso_local void @_ZN6Test201AILj1EE5test2Ev() + // CHECK-LABEL: define void @_ZN6Test201AILj1EE5test2Ev() void A<1>::test2() {} // CHECK: declare void @_ZN6Test201AILj1EE5test3Ev() @@ -684,8 +684,8 @@ template<> void C::f() { } - // CHECK-LABEL: define dso_local void @_ZN6test261CIiE1fEv - // CHECK-HIDDEN-LABEL: define dso_local void @_ZN6test261CIiE1fEv + // CHECK-LABEL: define void @_ZN6test261CIiE1fEv + // CHECK-HIDDEN-LABEL: define void @_ZN6test261CIiE1fEv } namespace test31 { @@ -709,8 +709,8 @@ }; void A::B::baz() { } - // CHECK-LABEL: define dso_local void @_ZN6test321A1B3bazEv - // CHECK-HIDDEN-LABEL: define dso_local void @_ZN6test321A1B3bazEv + // CHECK-LABEL: define void @_ZN6test321A1B3bazEv + // CHECK-HIDDEN-LABEL: define void @_ZN6test321A1B3bazEv } namespace test33 { @@ -829,8 +829,8 @@ }; void bar::zed() { } - // CHECK-LABEL: define dso_local void @_ZN6test423barINS_3fooEE3zedEv - // CHECK-HIDDEN-LABEL: define dso_local void @_ZN6test423barINS_3fooEE3zedEv + // CHECK-LABEL: define void @_ZN6test423barINS_3fooEE3zedEv + // CHECK-HIDDEN-LABEL: define void @_ZN6test423barINS_3fooEE3zedEv } namespace test43 { @@ -842,8 +842,8 @@ template <> DEFAULT void bar() { } - // CHECK-LABEL: define dso_local void @_ZN6test433barINS_3fooEEEvv - // CHECK-HIDDEN-LABEL: define dso_local void @_ZN6test433barINS_3fooEEEvv + // CHECK-LABEL: define void @_ZN6test433barINS_3fooEEEvv + // CHECK-HIDDEN-LABEL: define void @_ZN6test433barINS_3fooEEEvv } namespace test44 { @@ -1208,10 +1208,10 @@ static void foo() {} }; - // CHECK-LABEL: define dso_local void @_ZN6test651BINS_1AEE4funcEv() + // CHECK-LABEL: define void @_ZN6test651BINS_1AEE4funcEv() template <> DEFAULT void B::func() {} - // CHECK-LABEL: define dso_local void @_ZN6test651BINS_1AEE6funcT2IS1_EEvv() + // CHECK-LABEL: define void @_ZN6test651BINS_1AEE6funcT2IS1_EEvv() template <> template <> DEFAULT void B::funcT2() {} // CHECK-LABEL: define linkonce_odr void @_ZN6test651BINS_1AEE6funcT1IiEEvv() @@ -1314,6 +1314,6 @@ } namespace foo __attribute__((visibility("hidden"))) { } - // CHECK-LABEL: define dso_local void @_ZN6test693foo1fEv + // CHECK-LABEL: define void @_ZN6test693foo1fEv // CHECK-HIDDEN-LABEL: define hidden void @_ZN6test693foo1fEv }