[cfe-commits] r76079 - /cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Chris Lattner sabre at nondot.org
Thu Jul 16 09:48:29 PDT 2009


Author: lattner
Date: Thu Jul 16 11:48:25 2009
New Revision: 76079

URL: http://llvm.org/viewvc/llvm-project?rev=76079&view=rev
Log:
use CreateRuntimeVariable to get __CFConstantStringClassReference
instead of doing it manually (which might end up getting auto-renamed),
fixing a FIXME. rdar://7065446

Modified:
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=76079&r1=76078&r2=76079&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Jul 16 11:48:25 2009
@@ -821,7 +821,9 @@
   
   // 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 @@
   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);





More information about the cfe-commits mailing list