Set dso_local for CFConstantStringClassReference.

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

llvm-svn: 327993
This commit is contained in:
Rafael Espindola 2018-03-20 15:48:00 +00:00
parent 62690e9d0e
commit dca06024e8
2 changed files with 8 additions and 8 deletions

View File

@ -3810,14 +3810,13 @@ CodeGenModule::GetAddrOfConstantCFString(const StringLiteral *Literal) {
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(const StringLiteral *Literal) {
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 =

View File

@ -31,7 +31,7 @@ __declspec(dllimport) long __CFConstantStringClassReference[];
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]