aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-07-16 16:48:25 +0000
committerChris Lattner <sabre@nondot.org>2009-07-16 16:48:25 +0000
commit9d4a15fd3b85434c43ea27562793de63a793321a (patch)
tree04123b427cb2deaa4f6eaf695d8892827b6a7b89 /lib/CodeGen/CodeGenModule.cpp
parent8f16756441450ed9fb39316e47d107fc2a1ef35b (diff)
use CreateRuntimeVariable to get __CFConstantStringClassReference
instead of doing it manually (which might end up getting auto-renamed), fixing a FIXME. rdar://7065446 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76079 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--lib/CodeGen/CodeGenModule.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 8e65ef09fe..d502d79d29 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -821,7 +821,9 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
// Strip off a bitcast if we got one back.
if (llvm::ConstantExpr *CE = dyn_cast<llvm::ConstantExpr>(Entry)) {
- assert(CE->getOpcode() == llvm::Instruction::BitCast);
+ assert(CE->getOpcode() == llvm::Instruction::BitCast ||
+ // all zero index gep.
+ CE->getOpcode() == llvm::Instruction::GetElementPtr);
Entry = CE->getOperand(0);
}
@@ -1237,19 +1239,12 @@ GetAddrOfConstantCFString(const StringLiteral *Literal) {
llvm::Constant *Zero = getLLVMContext().getNullValue(llvm::Type::Int32Ty);
llvm::Constant *Zeros[] = { Zero, Zero };
+ // If we don't already have it, get __CFConstantStringClassReference.
if (!CFConstantStringClassRef) {
const llvm::Type *Ty = getTypes().ConvertType(getContext().IntTy);
Ty = VMContext.getArrayType(Ty, 0);
-
- // FIXME: This is fairly broken if __CFConstantStringClassReference is
- // already defined, in that it will get renamed and the user will most
- // likely see an opaque error message. This is a general issue with relying
- // on particular names.
- llvm::GlobalVariable *GV =
- new llvm::GlobalVariable(getModule(), Ty, false,
- llvm::GlobalVariable::ExternalLinkage, 0,
- "__CFConstantStringClassReference");
-
+ llvm::Constant *GV = CreateRuntimeVariable(Ty,
+ "__CFConstantStringClassReference");
// Decay array -> ptr
CFConstantStringClassRef =
VMContext.getConstantExprGetElementPtr(GV, Zeros, 2);