r327993 - Set dso_local for CFConstantStringClassReference.

Rafael Espindola via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 20 08:48:00 PDT 2018


Author: rafael
Date: Tue Mar 20 08:48:00 2018
New Revision: 327993

URL: http://llvm.org/viewvc/llvm-project?rev=327993&view=rev
Log:
Set dso_local for CFConstantStringClassReference.

This one cannot use setGVProperties since it has special logic for
when it is dllimport or not.

Modified:
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp
    cfe/trunk/test/CodeGen/cfstring-windows.c

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=327993&r1=327992&r2=327993&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Mar 20 08:48:00 2018
@@ -3810,14 +3810,13 @@ CodeGenModule::GetAddrOfConstantCFString
   if (!CFConstantStringClassRef) {
     llvm::Type *Ty = getTypes().ConvertType(getContext().IntTy);
     Ty = llvm::ArrayType::get(Ty, 0);
-    llvm::Constant *GV =
-        CreateRuntimeVariable(Ty, "__CFConstantStringClassReference");
+    llvm::GlobalValue *GV = cast<llvm::GlobalValue>(
+        CreateRuntimeVariable(Ty, "__CFConstantStringClassReference"));
 
     if (getTriple().isOSBinFormatCOFF()) {
       IdentifierInfo &II = getContext().Idents.get(GV->getName());
       TranslationUnitDecl *TUDecl = getContext().getTranslationUnitDecl();
       DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
-      llvm::GlobalValue *CGV = cast<llvm::GlobalValue>(GV);
 
       const VarDecl *VD = nullptr;
       for (const auto &Result : DC->lookup(&II))
@@ -3825,13 +3824,14 @@ CodeGenModule::GetAddrOfConstantCFString
           break;
 
       if (!VD || !VD->hasAttr<DLLExportAttr>()) {
-        CGV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
-        CGV->setLinkage(llvm::GlobalValue::ExternalLinkage);
+        GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
+        GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
       } else {
-        CGV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
-        CGV->setLinkage(llvm::GlobalValue::ExternalLinkage);
+        GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
+        GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
       }
     }
+    setDSOLocal(GV);
 
     // Decay array -> ptr
     CFConstantStringClassRef =

Modified: cfe/trunk/test/CodeGen/cfstring-windows.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/cfstring-windows.c?rev=327993&r1=327992&r2=327993&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/cfstring-windows.c (original)
+++ cfe/trunk/test/CodeGen/cfstring-windows.c Tue Mar 20 08:48:00 2018
@@ -31,7 +31,7 @@ __declspec(dllimport) long __CFConstantS
 typedef struct __CFString *CFStringRef;
 const CFStringRef string = (CFStringRef)__builtin___CFStringMakeConstantString("string");
 
-// CHECK-CF-IN-CF-DECL: @__CFConstantStringClassReference = external dllexport global [0 x i32]
+// CHECK-CF-IN-CF-DECL: @__CFConstantStringClassReference = external dso_local dllexport global [0 x i32]
 // CHECK-CF-IN-CF-DEFN: @__CFConstantStringClassReference = common dso_local dllexport global [32 x i32]
 // CHECK-CF: @__CFConstantStringClassReference = external dllimport global [0 x i32]
 // CHECK-CF-EXTERN: @__CFConstantStringClassReference = external dllimport global [0 x i32]




More information about the cfe-commits mailing list