summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorKristina Brooks <kristina@nym.hush.com>2018-09-24 15:26:08 +0000
committerKristina Brooks <kristina@nym.hush.com>2018-09-24 15:26:08 +0000
commita6398cdcfced9c9301d9daffc1e3b78f739dff6b (patch)
tree329e650043f26354c885d422d940b9a67c09ebe4 /clang/lib/CodeGen/CodeGenModule.cpp
parent00865a48d18b49f2605a70aeb48b015c1f6f5708 (diff)
downloadbcm5719-llvm-a6398cdcfced9c9301d9daffc1e3b78f739dff6b.tar.gz
bcm5719-llvm-a6398cdcfced9c9301d9daffc1e3b78f739dff6b.zip
Revert "rL342883: [Clang][CodeGen][ObjC]: Fix CoreFoundation on ELF with `-fconstant-cfstrings`."
Seems to be causing buildbot failures, need to look into it. llvm-svn: 342893
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp63
1 files changed, 24 insertions, 39 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index baafa98d5c8..85fed525795 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4109,48 +4109,37 @@ CodeGenModule::GetAddrOfConstantCFString(const StringLiteral *Literal) {
llvm::Constant *Zero = llvm::Constant::getNullValue(Int32Ty);
llvm::Constant *Zeros[] = { Zero, Zero };
-
+
// If we don't already have it, get __CFConstantStringClassReference.
if (!CFConstantStringClassRef) {
llvm::Type *Ty = getTypes().ConvertType(getContext().IntTy);
Ty = llvm::ArrayType::get(Ty, 0);
- llvm::Constant *C =
- CreateRuntimeVariable(Ty, "__CFConstantStringClassReference");
-
- if (getTriple().isOSBinFormatELF() || getTriple().isOSBinFormatCOFF()) {
- llvm::GlobalValue *GV = nullptr;
-
- if ((GV = dyn_cast<llvm::GlobalValue>(C))) {
- IdentifierInfo &II = getContext().Idents.get(GV->getName());
- TranslationUnitDecl *TUDecl = getContext().getTranslationUnitDecl();
- DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
-
- const VarDecl *VD = nullptr;
- for (const auto &Result : DC->lookup(&II))
- if ((VD = dyn_cast<VarDecl>(Result)))
- break;
-
- if (getTriple().isOSBinFormatELF()) {
- if (!VD)
- GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
- }
- else {
- if (!VD || !VD->hasAttr<DLLExportAttr>()) {
- GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
- GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
- } else {
- GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
- GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
- }
- }
-
- setDSOLocal(GV);
+ 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);
+
+ const VarDecl *VD = nullptr;
+ for (const auto &Result : DC->lookup(&II))
+ if ((VD = dyn_cast<VarDecl>(Result)))
+ break;
+
+ if (!VD || !VD->hasAttr<DLLExportAttr>()) {
+ GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
+ GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
+ } else {
+ GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
+ GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
}
}
-
+ setDSOLocal(GV);
+
// Decay array -> ptr
CFConstantStringClassRef =
- llvm::ConstantExpr::getGetElementPtr(Ty, C, Zeros);
+ llvm::ConstantExpr::getGetElementPtr(Ty, GV, Zeros);
}
QualType CFTy = getContext().getCFConstantStringType();
@@ -4196,11 +4185,7 @@ CodeGenModule::GetAddrOfConstantCFString(const StringLiteral *Literal) {
if (getTriple().isOSBinFormatMachO())
GV->setSection(isUTF16 ? "__TEXT,__ustring"
: "__TEXT,__cstring,cstring_literals");
- // Make sure the literal ends up in .rodata to allow for safe ICF and for
- // the static linker to adjust permissions to read-only later on.
- else if (getTriple().isOSBinFormatELF())
- GV->setSection(".rodata");
-
+
// String.
llvm::Constant *Str =
llvm::ConstantExpr::getGetElementPtr(GV->getValueType(), GV, Zeros);
OpenPOWER on IntegriCloud