r324107 - Start setting dso_local in clang.

Rafael Espindola via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 2 09:17:39 PST 2018


Author: rafael
Date: Fri Feb  2 09:17:39 2018
New Revision: 324107

URL: http://llvm.org/viewvc/llvm-project?rev=324107&view=rev
Log:
Start setting dso_local in clang.

This starts adding dso_local to clang.

The hope is to eventually have TargetMachine::shouldAssumeDsoLocal go
away. My objective for now is to move enough of it to clang to remove
the need for the TargetMachine one to handle PIE copy relocations and
-fno-plt. With that it should then be easy to implement a
-fno-copy-reloc in clang.

This patch just adds the cases where we assume a symbol to be local
based on the file being compiled for an executable or a shared
library.

Added:
    cfe/trunk/test/CodeGen/dso-local-executable.c
    cfe/trunk/test/CodeGenCXX/dso-local-executable.cpp
Modified:
    cfe/trunk/lib/CodeGen/CGDecl.cpp
    cfe/trunk/lib/CodeGen/CGVTT.cpp
    cfe/trunk/lib/CodeGen/CGVTables.cpp
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp
    cfe/trunk/lib/CodeGen/CodeGenModule.h
    cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
    cfe/trunk/test/CodeGen/mbackchain-2.c
    cfe/trunk/test/CodeGen/mbackchain-3.c
    cfe/trunk/test/CodeGen/mips-vector-return.c
    cfe/trunk/test/CodeGen/split-stacks.c
    cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp
    cfe/trunk/test/CodeGenCXX/debug-info-template.cpp
    cfe/trunk/test/CodeGenCXX/float16-declarations.cpp
    cfe/trunk/test/CodeGenCXX/split-stacks.cpp
    cfe/trunk/test/Driver/lanai-unknown-unknown.cpp
    cfe/trunk/test/Driver/le32-unknown-nacl.cpp
    cfe/trunk/test/Driver/le64-unknown-unknown.cpp
    cfe/trunk/test/Driver/riscv32-toolchain.c
    cfe/trunk/test/Driver/riscv64-toolchain.c
    cfe/trunk/test/Frontend/ast-codegen.c

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=324107&r1=324106&r2=324107&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Fri Feb  2 09:17:39 2018
@@ -240,7 +240,7 @@ llvm::Constant *CodeGenModule::getOrCrea
       getModule(), LTy, Ty.isConstant(getContext()), Linkage, Init, Name,
       nullptr, llvm::GlobalVariable::NotThreadLocal, TargetAS);
   GV->setAlignment(getContext().getDeclAlign(&D).getQuantity());
-  setGlobalVisibility(GV, &D, ForDefinition);
+  setGVProperties(GV, &D, ForDefinition);
 
   if (supportsCOMDAT() && GV->isWeakForLinker())
     GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));
@@ -344,6 +344,7 @@ CodeGenFunction::AddInitializerToStaticV
                                   OldGV->getThreadLocalMode(),
                            CGM.getContext().getTargetAddressSpace(D.getType()));
     GV->setVisibility(OldGV->getVisibility());
+    GV->setDSOLocal(OldGV->isDSOLocal());
     GV->setComdat(OldGV->getComdat());
 
     // Steal the name of the old global

Modified: cfe/trunk/lib/CodeGen/CGVTT.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTT.cpp?rev=324107&r1=324106&r2=324107&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVTT.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTT.cpp Fri Feb  2 09:17:39 2018
@@ -100,7 +100,7 @@ CodeGenVTables::EmitVTTDefinition(llvm::
     VTT->setComdat(CGM.getModule().getOrInsertComdat(VTT->getName()));
 
   // Set the right visibility.
-  CGM.setGlobalVisibility(VTT, RD, ForDefinition);
+  CGM.setGVProperties(VTT, RD, ForDefinition);
 }
 
 llvm::GlobalVariable *CodeGenVTables::GetAddrOfVTT(const CXXRecordDecl *RD) {

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=324107&r1=324106&r2=324107&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Fri Feb  2 09:17:39 2018
@@ -51,7 +51,7 @@ llvm::Constant *CodeGenModule::GetAddrOf
 
 static void setThunkVisibility(CodeGenModule &CGM, const CXXMethodDecl *MD,
                                const ThunkInfo &Thunk, llvm::Function *Fn) {
-  CGM.setGlobalVisibility(Fn, MD, ForDefinition);
+  CGM.setGVProperties(Fn, MD, ForDefinition);
 }
 
 static void setThunkProperties(CodeGenModule &CGM, const ThunkInfo &Thunk,
@@ -730,7 +730,7 @@ CodeGenVTables::GenerateConstructionVTab
   // Create the variable that will hold the construction vtable.
   llvm::GlobalVariable *VTable =
     CGM.CreateOrReplaceCXXRuntimeVariable(Name, VTType, Linkage);
-  CGM.setGlobalVisibility(VTable, RD, ForDefinition);
+  CGM.setGVProperties(VTable, RD, ForDefinition);
 
   // V-tables are always unnamed_addr.
   VTable->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=324107&r1=324106&r2=324107&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Feb  2 09:17:39 2018
@@ -717,6 +717,63 @@ void CodeGenModule::setGlobalVisibility(
     GV->setVisibility(GetLLVMVisibility(LV.getVisibility()));
 }
 
+static bool shouldAssumeDSOLocal(const CodeGenModule &CGM,
+                                 llvm::GlobalValue *GV, const NamedDecl *D,
+                                 ForDefinition_t IsForDefinition) {
+  const llvm::Triple &TT = CGM.getTriple();
+  // Only handle 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)
+    return false;
+
+  // A definition cannot be preempted from an executable.
+  if (IsForDefinition)
+    return true;
+
+  // Most PIC code sequences that assume that a symbol is local cannot produce a
+  // 0 if it turns out the symbol is undefined. While this is ABI and relocation
+  // depended, it seems worth it to handle it here.
+  if (RM == llvm::Reloc::PIC_ && GV->hasExternalWeakLinkage())
+    return false;
+
+  // PPC has no copy relocations and cannot use a plt entry as a symbol address.
+  llvm::Triple::ArchType Arch = TT.getArch();
+  if (Arch == llvm::Triple::ppc || Arch == llvm::Triple::ppc64 ||
+      Arch == llvm::Triple::ppc64le)
+    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 we can use a plt entry as the symbol address we can assume it
+  // is local.
+  if (isa<FunctionDecl>(D) && !CGOpts.NoPLT)
+    return true;
+
+  // Otherwise don't assue it is local.
+  return false;
+}
+
+void CodeGenModule::setDSOLocal(llvm::GlobalValue *GV, const NamedDecl *D,
+                                ForDefinition_t IsForDefinition) const {
+  if (shouldAssumeDSOLocal(*this, GV, D, IsForDefinition))
+    GV->setDSOLocal(true);
+}
+
+void CodeGenModule::setGVProperties(llvm::GlobalValue *GV, const NamedDecl *D,
+                                    ForDefinition_t IsForDefinition) const {
+  setGlobalVisibility(GV, D, IsForDefinition);
+  setDSOLocal(GV, D, IsForDefinition);
+}
+
 static llvm::GlobalVariable::ThreadLocalMode GetLLVMTLSModel(StringRef S) {
   return llvm::StringSwitch<llvm::GlobalVariable::ThreadLocalMode>(S)
       .Case("global-dynamic", llvm::GlobalVariable::GeneralDynamicTLSModel)
@@ -1174,7 +1231,7 @@ void CodeGenModule::SetLLVMFunctionAttri
 void CodeGenModule::SetCommonAttributes(const Decl *D,
                                         llvm::GlobalValue *GV) {
   if (const auto *ND = dyn_cast_or_null<NamedDecl>(D))
-    setGlobalVisibility(GV, ND, ForDefinition);
+    setGVProperties(GV, ND, ForDefinition);
   else
     GV->setVisibility(llvm::GlobalValue::DefaultVisibility);
 
@@ -1316,7 +1373,7 @@ void CodeGenModule::SetFunctionAttribute
   // overridden by a definition.
 
   setLinkageForGV(F, FD);
-  setGlobalVisibility(F, FD, NotForDefinition);
+  setGVProperties(F, FD, NotForDefinition);
 
   if (FD->getAttr<PragmaClangTextSectionAttr>()) {
     F->addFnAttr("implicit-section-name");
@@ -2638,7 +2695,7 @@ CodeGenModule::GetOrCreateLLVMGlobal(Str
     GV->setAlignment(getContext().getDeclAlign(D).getQuantity());
 
     setLinkageForGV(GV, D);
-    setGlobalVisibility(GV, D, NotForDefinition);
+    setGVProperties(GV, D, NotForDefinition);
 
     if (D->getTLSKind()) {
       if (D->getTLSKind() == VarDecl::TLS_Dynamic)
@@ -3457,7 +3514,7 @@ void CodeGenModule::EmitGlobalFunctionDe
   setFunctionDLLStorageClass(GD, Fn);
 
   // FIXME: this is redundant with part of setFunctionDefinitionAttributes
-  setGlobalVisibility(Fn, D, ForDefinition);
+  setGVProperties(Fn, D, ForDefinition);
 
   MaybeHandleStaticInExternC(D, Fn);
 
@@ -4053,7 +4110,7 @@ ConstantAddress CodeGenModule::GetAddrOf
       getModule(), Type, Constant, Linkage, InitialValue, Name.c_str(),
       /*InsertBefore=*/nullptr, llvm::GlobalVariable::NotThreadLocal, TargetAS);
   if (emitter) emitter->finalize(GV);
-  setGlobalVisibility(GV, VD, ForDefinition);
+  setGVProperties(GV, VD, ForDefinition);
   GV->setAlignment(Align.getQuantity());
   if (supportsCOMDAT() && GV->isWeakForLinker())
     GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=324107&r1=324106&r2=324107&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Fri Feb  2 09:17:39 2018
@@ -722,6 +722,12 @@ public:
   void setGlobalVisibility(llvm::GlobalValue *GV, const NamedDecl *D,
                            ForDefinition_t IsForDefinition) const;
 
+  void setDSOLocal(llvm::GlobalValue *GV, const NamedDecl *D,
+                   ForDefinition_t IsForDefinition) const;
+
+  void setGVProperties(llvm::GlobalValue *GV, const NamedDecl *D,
+                       ForDefinition_t IsForDefinition) const;
+
   /// Set the TLS mode for the given LLVM GlobalValue for the thread-local
   /// variable declaration D.
   void setTLSMode(llvm::GlobalValue *GV, const VarDecl &D) const;

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=324107&r1=324106&r2=324107&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Fri Feb  2 09:17:39 2018
@@ -1531,7 +1531,7 @@ void ItaniumCXXABI::emitVTableDefinition
     VTable->setComdat(CGM.getModule().getOrInsertComdat(VTable->getName()));
 
   // Set the right visibility.
-  CGM.setGlobalVisibility(VTable, RD, ForDefinition);
+  CGM.setGVProperties(VTable, RD, ForDefinition);
 
   // Use pointer alignment for the vtable. Otherwise we would align them based
   // on the size of the initializer which doesn't make sense as only single
@@ -1641,7 +1641,7 @@ llvm::GlobalVariable *ItaniumCXXABI::get
   VTable = CGM.CreateOrReplaceCXXRuntimeVariable(
       Name, VTableType, llvm::GlobalValue::ExternalLinkage);
   VTable->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
-  CGM.setGlobalVisibility(VTable, RD, NotForDefinition);
+  CGM.setGVProperties(VTable, RD, NotForDefinition);
 
   if (RD->hasAttr<DLLImportAttr>())
     VTable->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
@@ -2052,6 +2052,7 @@ void ItaniumCXXABI::EmitGuardedInit(Code
                                      false, var->getLinkage(),
                                      llvm::ConstantInt::get(guardTy, 0),
                                      guardName.str());
+    guard->setDSOLocal(var->isDSOLocal());
     guard->setVisibility(var->getVisibility());
     // If the variable is thread-local, so is its guard variable.
     guard->setThreadLocalMode(var->getThreadLocalMode());
@@ -3212,7 +3213,10 @@ llvm::Constant *ItaniumRTTIBuilder::Buil
     llvmVisibility = CodeGenModule::GetLLVMVisibility(Ty->getVisibility());
 
   TypeName->setVisibility(llvmVisibility);
+  CGM.setDSOLocal(TypeName, Ty->getAsCXXRecordDecl(), ForDefinition);
+
   GV->setVisibility(llvmVisibility);
+  CGM.setDSOLocal(GV, Ty->getAsCXXRecordDecl(), ForDefinition);
 
   if (CGM.getTriple().isWindowsItaniumEnvironment()) {
     auto RD = Ty->getAsCXXRecordDecl();

Added: cfe/trunk/test/CodeGen/dso-local-executable.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/dso-local-executable.c?rev=324107&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/dso-local-executable.c (added)
+++ cfe/trunk/test/CodeGen/dso-local-executable.c Fri Feb  2 09:17:39 2018
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm -mrelocation-model static %s -o - | FileCheck --check-prefix=STATIC %s
+// STATIC-DAG: @bar = external dso_local global i32
+// STATIC-DAG: @weak_bar = extern_weak dso_local global i32
+// STATIC-DAG: declare dso_local void @foo()
+// STATIC-DAG: @baz = dso_local global i32 42
+// STATIC-DAG: define dso_local i32* @zed()
+
+// 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
+// PIE-COPY-DAG: @weak_bar = extern_weak global i32
+// PIE-COPY-DAG: declare dso_local void @foo()
+// PIE-COPY-DAG: @baz = dso_local global i32 42
+// PIE-COPY-DAG: define dso_local i32* @zed()
+
+// 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
+// PIE-DAG: @weak_bar = extern_weak global i32
+// PIE-DAG: declare dso_local void @foo()
+// PIE-DAG: @baz = dso_local global i32 42
+// PIE-DAG: define dso_local i32* @zed()
+
+// 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
+// NOPLT-DAG: @weak_bar = extern_weak dso_local global i32
+// NOPLT-DAG: declare void @foo()
+// NOPLT-DAG: @baz = dso_local global i32 42
+// NOPLT-DAG: define dso_local i32* @zed()
+
+// 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
+// PIE-COPY-NOPLT-DAG: @weak_bar = extern_weak global i32
+// 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()
+
+// 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
+// PIE-NO-PLT-DAG: @bar = external global i32
+// PIE-NO-PLT-DAG: @weak_bar = extern_weak global i32
+// 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()
+
+// RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm %s -o - | FileCheck --check-prefix=SHARED %s
+// SHARED-DAG: @bar = external global i32
+// SHARED-DAG: @weak_bar = extern_weak global i32
+// SHARED-DAG: declare void @foo()
+// SHARED-DAG: @baz = global i32 42
+// SHARED-DAG: define i32* @zed()
+
+extern int bar;
+__attribute__((weak)) extern int weak_bar;
+void foo(void);
+
+int baz = 42;
+int *zed() {
+  foo();
+  return baz ? &weak_bar : &bar;
+}

Modified: cfe/trunk/test/CodeGen/mbackchain-2.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mbackchain-2.c?rev=324107&r1=324106&r2=324107&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/mbackchain-2.c (original)
+++ cfe/trunk/test/CodeGen/mbackchain-2.c Fri Feb  2 09:17:39 2018
@@ -1,6 +1,6 @@
 // RUN: %clang -mbackchain --target=s390x-linux -S -emit-llvm -o - %s | FileCheck %s
 
-// CHECK: define void @foo() [[NUW:#[0-9]+]]
+// CHECK: define dso_local void @foo() [[NUW:#[0-9]+]]
 void foo(void) {
 }
 

Modified: cfe/trunk/test/CodeGen/mbackchain-3.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mbackchain-3.c?rev=324107&r1=324106&r2=324107&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/mbackchain-3.c (original)
+++ cfe/trunk/test/CodeGen/mbackchain-3.c Fri Feb  2 09:17:39 2018
@@ -1,6 +1,6 @@
 // RUN: %clang -mno-backchain --target=s390x-linux -S -emit-llvm -o - %s | FileCheck %s
 
-// CHECK: define void @foo() [[NUW:#[0-9]+]]
+// CHECK: define dso_local void @foo() [[NUW:#[0-9]+]]
 void foo(void) {
 }
 

Modified: cfe/trunk/test/CodeGen/mips-vector-return.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mips-vector-return.c?rev=324107&r1=324106&r2=324107&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/mips-vector-return.c (original)
+++ cfe/trunk/test/CodeGen/mips-vector-return.c Fri Feb  2 09:17:39 2018
@@ -8,13 +8,13 @@ typedef float  v4sf __attribute__ ((__ve
 typedef double v4df __attribute__ ((__vector_size__ (32)));
 typedef int v4i32 __attribute__ ((__vector_size__ (16)));
 
-// O32-LABEL: define void @test_v4sf(<4 x float>* noalias nocapture sret
+// O32-LABEL: define dso_local void @test_v4sf(<4 x float>* noalias nocapture sret
 // N64: define inreg { i64, i64 } @test_v4sf
 v4sf test_v4sf(float a) {
   return (v4sf){0.0f, a, 0.0f, 0.0f};
 }
 
-// O32-LABEL: define void @test_v4df(<4 x double>* noalias nocapture sret
+// O32-LABEL: define dso_local void @test_v4df(<4 x double>* noalias nocapture sret
 // N64-LABEL: define void @test_v4df(<4 x double>* noalias nocapture sret
 v4df test_v4df(double a) {
   return (v4df){0.0, a, 0.0, 0.0};
@@ -23,7 +23,7 @@ v4df test_v4df(double a) {
 // O32 returns integer vectors whose size is equal to or smaller than 16-bytes
 // in integer registers.
 //
-// O32: define inreg { i32, i32, i32, i32 } @test_v4i32
+// O32: define dso_local inreg { i32, i32, i32, i32 } @test_v4i32
 // N64: define inreg { i64, i64 } @test_v4i32
 v4i32 test_v4i32(int a) {
   return (v4i32){0, a, 0, 0};

Modified: cfe/trunk/test/CodeGen/split-stacks.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/split-stacks.c?rev=324107&r1=324106&r2=324107&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/split-stacks.c (original)
+++ cfe/trunk/test/CodeGen/split-stacks.c Fri Feb  2 09:17:39 2018
@@ -14,13 +14,13 @@ int main() {
   return foo();
 }
 
-// CHECK-SEGSTK: define i32 @foo() [[SS:#[0-9]+]] {
-// CHECK-SEGSTK: define i32 @nosplit() [[NSS:#[0-9]+]] {
-// CHECK-SEGSTK: define i32 @main() [[SS]] {
+// CHECK-SEGSTK: define dso_local i32 @foo() [[SS:#[0-9]+]] {
+// CHECK-SEGSTK: define dso_local i32 @nosplit() [[NSS:#[0-9]+]] {
+// CHECK-SEGSTK: define dso_local i32 @main() [[SS]] {
 // CHECK-SEGSTK-NOT: [[NSS]] = { {{.*}} "split-stack" {{.*}} }
 // CHECK-SEGSTK: [[SS]] = { {{.*}} "split-stack" {{.*}} }
 // CHECK-SEGSTK-NOT: [[NSS]] = { {{.*}} "split-stack" {{.*}} }
 
-// CHECK-NOSEGSTK: define i32 @foo() #0 {
-// CHECK-NOSEGSTK: define i32 @main() #0 {
+// CHECK-NOSEGSTK: define dso_local i32 @foo() #0 {
+// CHECK-NOSEGSTK: define dso_local i32 @main() #0 {
 // CHECK-NOSEGSTK-NOT: #0 = { {{.*}} "split-stack" {{.*}} }

Modified: cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp?rev=324107&r1=324106&r2=324107&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp Fri Feb  2 09:17:39 2018
@@ -3,9 +3,9 @@
 // RUN: %clangxx -target x86_64-unknown-unknown -g -std=c++11 %s -emit-llvm -S -o - | FileCheck %s
 // PR14471
 
-// CHECK: @_ZN1C1aE = global i32 4, align 4, !dbg [[A:![0-9]+]]
-// CHECK: @_ZN1C1bE = global i32 2, align 4, !dbg [[B:![0-9]+]]
-// CHECK: @_ZN1C1cE = global i32 1, align 4, !dbg [[C:![0-9]+]]
+// CHECK: @_ZN1C1aE = dso_local global i32 4, align 4, !dbg [[A:![0-9]+]]
+// CHECK: @_ZN1C1bE = dso_local global i32 2, align 4, !dbg [[B:![0-9]+]]
+// CHECK: @_ZN1C1cE = dso_local global i32 1, align 4, !dbg [[C:![0-9]+]]
 
 enum X {
   Y

Modified: cfe/trunk/test/CodeGenCXX/debug-info-template.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-template.cpp?rev=324107&r1=324106&r2=324107&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-template.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-template.cpp Fri Feb  2 09:17:39 2018
@@ -1,8 +1,8 @@
 // RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - -std=c++11 | FileCheck %s
 
-// CHECK: @tci = global %"struct.TC<unsigned int, 2, &glb, &foo::e, &foo::f, &foo::g, 1, 2, 3>::nested" zeroinitializer, align 1, !dbg [[TCI:![0-9]+]]
-// CHECK: @tcn = global %struct.TC zeroinitializer, align 1, !dbg [[TCN:![0-9]+]]
-// CHECK: @nn = global %struct.NN zeroinitializer, align 1, !dbg [[NN:![0-9]+]]
+// CHECK: @tci = dso_local global %"struct.TC<unsigned int, 2, &glb, &foo::e, &foo::f, &foo::g, 1, 2, 3>::nested" zeroinitializer, align 1, !dbg [[TCI:![0-9]+]]
+// CHECK: @tcn = dso_local global %struct.TC zeroinitializer, align 1, !dbg [[TCN:![0-9]+]]
+// CHECK: @nn = dso_local global %struct.NN zeroinitializer, align 1, !dbg [[NN:![0-9]+]]
 
 // CHECK: !DICompileUnit(
 // CHECK: [[EMPTY:![0-9]*]] = !{}

Added: cfe/trunk/test/CodeGenCXX/dso-local-executable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dso-local-executable.cpp?rev=324107&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/dso-local-executable.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/dso-local-executable.cpp Fri Feb  2 09:17:39 2018
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -mrelocation-model static -emit-llvm %s -o - | FileCheck --check-prefix=STATIC %s
+
+// STATIC: @_ZTV1C = linkonce_odr dso_local unnamed_addr constant
+// STATIC: @_ZTS1C = linkonce_odr dso_local constant
+// STATIC: @_ZTI1C = linkonce_odr dso_local constant
+// STATIC: @_ZZ14useStaticLocalvE3obj = linkonce_odr dso_local global
+// STATIC: @_ZGVZN5guard1gEvE1a = linkonce_odr dso_local global
+// STATIC: define dso_local void @_ZN1CC2Ev(
+// STATIC: define dso_local void @_ZN1CC1Ev(
+// STATIC: define linkonce_odr dso_local void @_ZN1C3fooEv(
+
+struct C {
+  C();
+  virtual void foo() {}
+};
+C::C() {}
+
+struct HasVTable {
+  virtual void f();
+};
+inline HasVTable &useStaticLocal() {
+  static HasVTable obj;
+  return obj;
+}
+void useit() {
+  useStaticLocal();
+}
+
+namespace guard {
+int f();
+inline int g() {
+  static int a = f();
+  return a;
+}
+int h() {
+  return g();
+}
+} // namespace guard

Modified: cfe/trunk/test/CodeGenCXX/float16-declarations.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/float16-declarations.cpp?rev=324107&r1=324106&r2=324107&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/float16-declarations.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/float16-declarations.cpp Fri Feb  2 09:17:39 2018
@@ -29,18 +29,18 @@ namespace {
 /* File */
 
 _Float16 f1f;
-// CHECK-AARCH64-DAG: @f1f = global half 0xH0000, align 2
-// CHECK-X86-DAG: @f1f = global half 0xH0000, align 2
+// CHECK-AARCH64-DAG: @f1f = dso_local global half 0xH0000, align 2
+// CHECK-X86-DAG: @f1f = dso_local global half 0xH0000, align 2
 
 _Float16 f2f = 32.4;
-// CHECK-DAG: @f2f = global half 0xH500D, align 2
+// CHECK-DAG: @f2f = dso_local global half 0xH500D, align 2
 
 _Float16 arr1f[10];
-// CHECK-AARCH64-DAG: @arr1f = global [10 x half] zeroinitializer, align 2
-// CHECK-X86-DAG: @arr1f = global [10 x half] zeroinitializer, align 16
+// CHECK-AARCH64-DAG: @arr1f = dso_local global [10 x half] zeroinitializer, align 2
+// CHECK-X86-DAG: @arr1f = dso_local global [10 x half] zeroinitializer, align 16
 
 _Float16 arr2f[] = { -1.2, -3.0, -3.e4 };
-// CHECK-DAG: @arr2f = global [3 x half] [half 0xHBCCD, half 0xHC200, half 0xHF753], align 2
+// CHECK-DAG: @arr2f = dso_local global [3 x half] [half 0xHBCCD, half 0xHC200, half 0xHF753], align 2
 
 _Float16 func1f(_Float16 arg);
 
@@ -51,24 +51,24 @@ class C1 {
   _Float16 f1c;
 
   static const _Float16 f2c;
-// CHECK-DAG: @_ZN2C13f2cE = external constant half, align 2
+// CHECK-DAG: @_ZN2C13f2cE = external dso_local constant half, align 2
 
   volatile _Float16 f3c;
 
 public:
   C1(_Float16 arg) : f1c(arg), f3c(arg) { }
 // Check that we mangle _Float16 to DF16_
-// CHECK-DAG: define linkonce_odr void @_ZN2C1C2EDF16_(%class.C1*{{.*}}, half{{.*}})
+// CHECK-DAG: define linkonce_odr dso_local void @_ZN2C1C2EDF16_(%class.C1*{{.*}}, half{{.*}})
 
   _Float16 func1c(_Float16 arg ) {
     return f1c + arg;
   }
-// CHECK-DAG: define linkonce_odr half @_ZN2C16func1cEDF16_(%class.C1*{{.*}}, half{{.*}})
+// CHECK-DAG: define linkonce_odr dso_local half @_ZN2C16func1cEDF16_(%class.C1*{{.*}}, half{{.*}})
 
   static _Float16 func2c(_Float16 arg) {
     return arg * C1::f2c;
   }
-// CHECK-DAG: define linkonce_odr half @_ZN2C16func2cEDF16_(half{{.*}})
+// CHECK-DAG: define linkonce_odr dso_local half @_ZN2C16func2cEDF16_(half{{.*}})
 };
 
 /*  Template */
@@ -76,7 +76,7 @@ public:
 template <class C> C func1t(C arg) {
   return arg * 2.f16;
 }
-// CHECK-DAG: define linkonce_odr half @_Z6func1tIDF16_ET_S0_(half{{.*}})
+// CHECK-DAG: define linkonce_odr dso_local half @_Z6func1tIDF16_ET_S0_(half{{.*}})
 
 template <class C> struct S1 {
   C mem1;

Modified: cfe/trunk/test/CodeGenCXX/split-stacks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/split-stacks.cpp?rev=324107&r1=324106&r2=324107&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/split-stacks.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/split-stacks.cpp Fri Feb  2 09:17:39 2018
@@ -16,18 +16,18 @@ int nosplit() {
   return tnosplit<int>();
 }
 
-// CHECK-SEGSTK: define i32 @_Z3foov() [[SS:#[0-9]+]] {
-// CHECK-SEGSTK: define i32 @_Z7nosplitv() [[NSS1:#[0-9]+]] {
-// CHECK-SEGSTK: define linkonce_odr i32 @_Z8tnosplitIiEiv() [[NSS2:#[0-9]+]] comdat {
+// CHECK-SEGSTK: define dso_local i32 @_Z3foov() [[SS:#[0-9]+]] {
+// CHECK-SEGSTK: define dso_local i32 @_Z7nosplitv() [[NSS1:#[0-9]+]] {
+// CHECK-SEGSTK: define linkonce_odr dso_local i32 @_Z8tnosplitIiEiv() [[NSS2:#[0-9]+]] comdat {
 // CHECK-SEGSTK-NOT: [[NSS1]] = { {{.*}} "split-stack" {{.*}} }
 // CHECK-SEGSTK-NOT: [[NSS2]] = { {{.*}} "split-stack" {{.*}} }
 // CHECK-SEGSTK: [[SS]] = { {{.*}} "split-stack" {{.*}} }
 // CHECK-SEGSTK-NOT: [[NSS1]] = { {{.*}} "split-stack" {{.*}} }
 // CHECK-SEGSTK-NOT: [[NSS2]] = { {{.*}} "split-stack" {{.*}} }
 
-// CHECK-NOSEGSTK: define i32 @_Z3foov() [[NSS0:#[0-9]+]] {
-// CHECK-NOSEGSTK: define i32 @_Z7nosplitv() [[NSS1:#[0-9]+]] {
-// CHECK-NOSEGSTK: define linkonce_odr i32 @_Z8tnosplitIiEiv() [[NSS2:#[0-9]+]] comdat {
+// CHECK-NOSEGSTK: define dso_local i32 @_Z3foov() [[NSS0:#[0-9]+]] {
+// CHECK-NOSEGSTK: define dso_local i32 @_Z7nosplitv() [[NSS1:#[0-9]+]] {
+// CHECK-NOSEGSTK: define linkonce_odr dso_local i32 @_Z8tnosplitIiEiv() [[NSS2:#[0-9]+]] comdat {
 // CHECK-NOSEGSTK-NOT: [[NSS1]] = { {{.*}} "split-stack" {{.*}} }
 // CHECK-NOSEGSTK-NOT: [[NSS2]] = { {{.*}} "split-stack" {{.*}} }
 // CHECK-NOSEGSTK-NOT: [[NSS3]] = { {{.*}} "split-stack" {{.*}} }

Modified: cfe/trunk/test/Driver/lanai-unknown-unknown.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/lanai-unknown-unknown.cpp?rev=324107&r1=324106&r2=324107&view=diff
==============================================================================
--- cfe/trunk/test/Driver/lanai-unknown-unknown.cpp (original)
+++ cfe/trunk/test/Driver/lanai-unknown-unknown.cpp Fri Feb  2 09:17:39 2018
@@ -11,25 +11,25 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
 
 extern "C" {
 
-// CHECK: @align_c = global i32 1
+// CHECK: @align_c = dso_local global i32 1
 int align_c = __alignof(char);
 
-// CHECK: @align_s = global i32 2
+// CHECK: @align_s = dso_local global i32 2
 int align_s = __alignof(short);
 
-// CHECK: @align_i = global i32 4
+// CHECK: @align_i = dso_local global i32 4
 int align_i = __alignof(int);
 
-// CHECK: @align_l = global i32 4
+// CHECK: @align_l = dso_local global i32 4
 int align_l = __alignof(long);
 
-// CHECK: @align_ll = global i32 8
+// CHECK: @align_ll = dso_local global i32 8
 int align_ll = __alignof(long long);
 
-// CHECK: @align_p = global i32 4
+// CHECK: @align_p = dso_local global i32 4
 int align_p = __alignof(void*);
 
-// CHECK: @align_vl = global i32 4
+// CHECK: @align_vl = dso_local global i32 4
 int align_vl = __alignof(va_list);
 
 // Check types

Modified: cfe/trunk/test/Driver/le32-unknown-nacl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/le32-unknown-nacl.cpp?rev=324107&r1=324106&r2=324107&view=diff
==============================================================================
--- cfe/trunk/test/Driver/le32-unknown-nacl.cpp (original)
+++ cfe/trunk/test/Driver/le32-unknown-nacl.cpp Fri Feb  2 09:17:39 2018
@@ -10,34 +10,34 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
 
 extern "C" {
 
-// CHECK: @align_c = global i32 1
+// CHECK: @align_c = dso_local global i32 1
 int align_c = __alignof(char);
 
-// CHECK: @align_s = global i32 2
+// CHECK: @align_s = dso_local global i32 2
 int align_s = __alignof(short);
 
-// CHECK: @align_i = global i32 4
+// CHECK: @align_i = dso_local global i32 4
 int align_i = __alignof(int);
 
-// CHECK: @align_l = global i32 4
+// CHECK: @align_l = dso_local global i32 4
 int align_l = __alignof(long);
 
-// CHECK: @align_ll = global i32 8
+// CHECK: @align_ll = dso_local global i32 8
 int align_ll = __alignof(long long);
 
-// CHECK: @align_p = global i32 4
+// CHECK: @align_p = dso_local global i32 4
 int align_p = __alignof(void*);
 
-// CHECK: @align_f = global i32 4
+// CHECK: @align_f = dso_local global i32 4
 int align_f = __alignof(float);
 
-// CHECK: @align_d = global i32 8
+// CHECK: @align_d = dso_local global i32 8
 int align_d = __alignof(double);
 
-// CHECK: @align_ld = global i32 8
+// CHECK: @align_ld = dso_local global i32 8
 int align_ld = __alignof(long double);
 
-// CHECK: @align_vl = global i32 4
+// CHECK: @align_vl = dso_local global i32 4
 int align_vl = __alignof(va_list);
 
 // CHECK: __LITTLE_ENDIAN__defined

Modified: cfe/trunk/test/Driver/le64-unknown-unknown.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/le64-unknown-unknown.cpp?rev=324107&r1=324106&r2=324107&view=diff
==============================================================================
--- cfe/trunk/test/Driver/le64-unknown-unknown.cpp (original)
+++ cfe/trunk/test/Driver/le64-unknown-unknown.cpp Fri Feb  2 09:17:39 2018
@@ -9,34 +9,34 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
 
 extern "C" {
 
-// CHECK: @align_c = global i32 1
+// CHECK: @align_c = dso_local global i32 1
 int align_c = __alignof(char);
 
-// CHECK: @align_s = global i32 2
+// CHECK: @align_s = dso_local global i32 2
 int align_s = __alignof(short);
 
-// CHECK: @align_i = global i32 4
+// CHECK: @align_i = dso_local global i32 4
 int align_i = __alignof(int);
 
-// CHECK: @align_l = global i32 8
+// CHECK: @align_l = dso_local global i32 8
 int align_l = __alignof(long);
 
-// CHECK: @align_ll = global i32 8
+// CHECK: @align_ll = dso_local global i32 8
 int align_ll = __alignof(long long);
 
-// CHECK: @align_p = global i32 8
+// CHECK: @align_p = dso_local global i32 8
 int align_p = __alignof(void*);
 
-// CHECK: @align_f = global i32 4
+// CHECK: @align_f = dso_local global i32 4
 int align_f = __alignof(float);
 
-// CHECK: @align_d = global i32 8
+// CHECK: @align_d = dso_local global i32 8
 int align_d = __alignof(double);
 
-// CHECK: @align_ld = global i32 8
+// CHECK: @align_ld = dso_local global i32 8
 int align_ld = __alignof(long double);
 
-// CHECK: @align_vl = global i32 4
+// CHECK: @align_vl = dso_local global i32 4
 int align_vl = __alignof(va_list);
 
 // CHECK: __LITTLE_ENDIAN__defined

Modified: cfe/trunk/test/Driver/riscv32-toolchain.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/riscv32-toolchain.c?rev=324107&r1=324106&r2=324107&view=diff
==============================================================================
--- cfe/trunk/test/Driver/riscv32-toolchain.c (original)
+++ cfe/trunk/test/Driver/riscv32-toolchain.c Fri Feb  2 09:17:39 2018
@@ -41,37 +41,37 @@ typedef __SIZE_TYPE__ size_t;
 typedef __PTRDIFF_TYPE__ ptrdiff_t;
 typedef __WCHAR_TYPE__ wchar_t;
 
-// CHECK: @align_c = global i32 1
+// CHECK: @align_c = dso_local global i32 1
 int align_c = __alignof(char);
 
-// CHECK: @align_s = global i32 2
+// CHECK: @align_s = dso_local global i32 2
 int align_s = __alignof(short);
 
-// CHECK: @align_i = global i32 4
+// CHECK: @align_i = dso_local global i32 4
 int align_i = __alignof(int);
 
-// CHECK: @align_wc = global i32 4
+// CHECK: @align_wc = dso_local global i32 4
 int align_wc = __alignof(wchar_t);
 
-// CHECK: @align_l = global i32 4
+// CHECK: @align_l = dso_local global i32 4
 int align_l = __alignof(long);
 
-// CHECK: @align_ll = global i32 8
+// CHECK: @align_ll = dso_local global i32 8
 int align_ll = __alignof(long long);
 
-// CHECK: @align_p = global i32 4
+// CHECK: @align_p = dso_local global i32 4
 int align_p = __alignof(void*);
 
-// CHECK: @align_f = global i32 4
+// CHECK: @align_f = dso_local global i32 4
 int align_f = __alignof(float);
 
-// CHECK: @align_d = global i32 8
+// CHECK: @align_d = dso_local global i32 8
 int align_d = __alignof(double);
 
-// CHECK: @align_ld = global i32 16
+// CHECK: @align_ld = dso_local global i32 16
 int align_ld = __alignof(long double);
 
-// CHECK: @align_vl = global i32 4
+// CHECK: @align_vl = dso_local global i32 4
 int align_vl = __alignof(va_list);
 
 // Check types
@@ -79,44 +79,44 @@ int align_vl = __alignof(va_list);
 // CHECK: zeroext i8 @check_char()
 char check_char() { return 0; }
 
-// CHECK: define signext i16 @check_short()
+// CHECK: define dso_local signext i16 @check_short()
 short check_short() { return 0; }
 
-// CHECK: define i32 @check_int()
+// CHECK: define dso_local i32 @check_int()
 int check_int() { return 0; }
 
-// CHECK: define i32 @check_wchar_t()
+// CHECK: define dso_local i32 @check_wchar_t()
 int check_wchar_t() { return 0; }
 
-// CHECK: define i32 @check_long()
+// CHECK: define dso_local i32 @check_long()
 long check_long() { return 0; }
 
-// CHECK: define i64 @check_longlong()
+// CHECK: define dso_local i64 @check_longlong()
 long long check_longlong() { return 0; }
 
-// CHECK: define zeroext i8 @check_uchar()
+// CHECK: define dso_local zeroext i8 @check_uchar()
 unsigned char check_uchar() { return 0; }
 
-// CHECK: define zeroext i16 @check_ushort()
+// CHECK: define dso_local zeroext i16 @check_ushort()
 unsigned short check_ushort() { return 0; }
 
-// CHECK: define i32 @check_uint()
+// CHECK: define dso_local i32 @check_uint()
 unsigned int check_uint() { return 0; }
 
-// CHECK: define i32 @check_ulong()
+// CHECK: define dso_local i32 @check_ulong()
 unsigned long check_ulong() { return 0; }
 
-// CHECK: define i64 @check_ulonglong()
+// CHECK: define dso_local i64 @check_ulonglong()
 unsigned long long check_ulonglong() { return 0; }
 
-// CHECK: define i32 @check_size_t()
+// CHECK: define dso_local i32 @check_size_t()
 size_t check_size_t() { return 0; }
 
-// CHECK: define float @check_float()
+// CHECK: define dso_local float @check_float()
 float check_float() { return 0; }
 
-// CHECK: define double @check_double()
+// CHECK: define dso_local double @check_double()
 double check_double() { return 0; }
 
-// CHECK: define fp128 @check_longdouble()
+// CHECK: define dso_local fp128 @check_longdouble()
 long double check_longdouble() { return 0; }

Modified: cfe/trunk/test/Driver/riscv64-toolchain.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/riscv64-toolchain.c?rev=324107&r1=324106&r2=324107&view=diff
==============================================================================
--- cfe/trunk/test/Driver/riscv64-toolchain.c (original)
+++ cfe/trunk/test/Driver/riscv64-toolchain.c Fri Feb  2 09:17:39 2018
@@ -10,82 +10,82 @@ typedef __SIZE_TYPE__ size_t;
 typedef __PTRDIFF_TYPE__ ptrdiff_t;
 typedef __WCHAR_TYPE__ wchar_t;
 
-// CHECK: @align_c = global i32 1
+// CHECK: @align_c = dso_local global i32 1
 int align_c = __alignof(char);
 
-// CHECK: @align_s = global i32 2
+// CHECK: @align_s = dso_local global i32 2
 int align_s = __alignof(short);
 
-// CHECK: @align_i = global i32 4
+// CHECK: @align_i = dso_local global i32 4
 int align_i = __alignof(int);
 
-// CHECK: @align_wc = global i32 4
+// CHECK: @align_wc = dso_local global i32 4
 int align_wc = __alignof(wchar_t);
 
-// CHECK: @align_l = global i32 8
+// CHECK: @align_l = dso_local global i32 8
 int align_l = __alignof(long);
 
-// CHECK: @align_ll = global i32 8
+// CHECK: @align_ll = dso_local global i32 8
 int align_ll = __alignof(long long);
 
-// CHECK: @align_p = global i32 8
+// CHECK: @align_p = dso_local global i32 8
 int align_p = __alignof(void*);
 
-// CHECK: @align_f = global i32 4
+// CHECK: @align_f = dso_local global i32 4
 int align_f = __alignof(float);
 
-// CHECK: @align_d = global i32 8
+// CHECK: @align_d = dso_local global i32 8
 int align_d = __alignof(double);
 
-// CHECK: @align_ld = global i32 16
+// CHECK: @align_ld = dso_local global i32 16
 int align_ld = __alignof(long double);
 
-// CHECK: @align_vl = global i32 8
+// CHECK: @align_vl = dso_local global i32 8
 int align_vl = __alignof(va_list);
 
 // Check types
 
-// CHECK: define zeroext i8 @check_char()
+// CHECK: define dso_local zeroext i8 @check_char()
 char check_char() { return 0; }
 
-// CHECK: define signext i16 @check_short()
+// CHECK: define dso_local signext i16 @check_short()
 short check_short() { return 0; }
 
-// CHECK: define signext i32 @check_int()
+// CHECK: define dso_local signext i32 @check_int()
 int check_int() { return 0; }
 
-// CHECK: define signext i32 @check_wchar_t()
+// CHECK: define dso_local signext i32 @check_wchar_t()
 int check_wchar_t() { return 0; }
 
-// CHECK: define i64 @check_long()
+// CHECK: define dso_local i64 @check_long()
 long check_long() { return 0; }
 
-// CHECK: define i64 @check_longlong()
+// CHECK: define dso_local i64 @check_longlong()
 long long check_longlong() { return 0; }
 
-// CHECK: define zeroext i8 @check_uchar()
+// CHECK: define dso_local zeroext i8 @check_uchar()
 unsigned char check_uchar() { return 0; }
 
-// CHECK: define zeroext i16 @check_ushort()
+// CHECK: define dso_local zeroext i16 @check_ushort()
 unsigned short check_ushort() { return 0; }
 
-// CHECK: define signext i32 @check_uint()
+// CHECK: define dso_local signext i32 @check_uint()
 unsigned int check_uint() { return 0; }
 
-// CHECK: define i64 @check_ulong()
+// CHECK: define dso_local i64 @check_ulong()
 unsigned long check_ulong() { return 0; }
 
-// CHECK: define i64 @check_ulonglong()
+// CHECK: define dso_local i64 @check_ulonglong()
 unsigned long long check_ulonglong() { return 0; }
 
-// CHECK: define i64 @check_size_t()
+// CHECK: define dso_local i64 @check_size_t()
 size_t check_size_t() { return 0; }
 
-// CHECK: define float @check_float()
+// CHECK: define dso_local float @check_float()
 float check_float() { return 0; }
 
-// CHECK: define double @check_double()
+// CHECK: define dso_local double @check_double()
 double check_double() { return 0; }
 
-// CHECK: define fp128 @check_longdouble()
+// CHECK: define dso_local fp128 @check_longdouble()
 long double check_longdouble() { return 0; }

Modified: cfe/trunk/test/Frontend/ast-codegen.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/ast-codegen.c?rev=324107&r1=324106&r2=324107&view=diff
==============================================================================
--- cfe/trunk/test/Frontend/ast-codegen.c (original)
+++ cfe/trunk/test/Frontend/ast-codegen.c Fri Feb  2 09:17:39 2018
@@ -5,9 +5,9 @@
 // CHECK: module asm "foo"
 __asm__("foo");
 
-// CHECK: @g0 = common global i32 0, align 4
+// CHECK: @g0 = common dso_local global i32 0, align 4
 int g0;
 
-// CHECK: define i32 @f0()
+// CHECK: define dso_local i32 @f0()
 int f0() {
 }




More information about the cfe-commits mailing list