[cfe-commits] r64479 - in /cfe/trunk/lib/CodeGen: CGBlocks.cpp CodeGenModule.h

Mike Stump mrs at apple.com
Fri Feb 13 11:29:27 PST 2009


Author: mrs
Date: Fri Feb 13 13:29:27 2009
New Revision: 64479

URL: http://llvm.org/viewvc/llvm-project?rev=64479&view=rev
Log:
Move NSConcreteStackBlock into CGM.

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

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Fri Feb 13 13:29:27 2009
@@ -93,6 +93,24 @@
   return NSConcreteGlobalBlock;
 }
 
+llvm::Constant *CodeGenModule::getNSConcreteStackBlock() {
+  if (NSConcreteStackBlock)
+    return NSConcreteStackBlock;
+
+  const llvm::PointerType *PtrToInt8Ty
+    = llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
+  // FIXME: Wee should have a CodeGenModule::AddRuntimeVariable that does the
+  // same thing as CreateRuntimeFunction if there's already a variable with
+  // the same name.
+  NSConcreteStackBlock
+    = new llvm::GlobalVariable(PtrToInt8Ty, false, 
+                               llvm::GlobalValue::ExternalLinkage,
+                               0, "_NSConcreteStackBlock",
+                               &getModule());
+
+  return NSConcreteStackBlock;
+}
+
 llvm::Constant *CodeGenFunction::BuildBlockLiteralTmp() {
   // FIXME: Push up
   bool BlockHasCopyDispose = false;
@@ -110,21 +128,14 @@
     if (BlockHasCopyDispose)
       flags |= BLOCK_HAS_COPY_DISPOSE;
 
-    const llvm::PointerType *PtrToInt8Ty
-      = llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
-    // FIXME: static?  What if we start up a new, unrelated module?
-    // logically we want 1 per module.
-    static llvm::Constant *NSConcreteStackBlock_decl
-      = new llvm::GlobalVariable(PtrToInt8Ty, false, 
-                                 llvm::GlobalValue::ExternalLinkage,
-                                 0, "_NSConcreteStackBlock",
-                                 &CGM.getModule());
-    C = NSConcreteStackBlock_decl;
+    C = CGM.getNSConcreteStackBlock();
     if (!insideFunction ||
         (!BlockRefDeclList && !BlockByrefDeclList)) {
       C = CGM.getNSConcreteGlobalBlock();
       flags |= BLOCK_IS_GLOBAL;
     }
+    const llvm::PointerType *PtrToInt8Ty
+      = llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
     C = llvm::ConstantExpr::getBitCast(C, PtrToInt8Ty);
     Elts.push_back(C);
 

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Fri Feb 13 13:29:27 2009
@@ -123,6 +123,10 @@
   /// blocks.
   llvm::Constant *NSConcreteGlobalBlock;
 
+  /// NSConcreteStackBlock - Cached reference to the class poinnter for stack
+  /// blocks.
+  llvm::Constant *NSConcreteStackBlock;
+  
   const llvm::Type *BlockDescriptorType;
   const llvm::Type * GenericBlockLiteralType;
   struct {
@@ -141,6 +145,7 @@
   void Release();
 
   llvm::Constant *getNSConcreteGlobalBlock();
+  llvm::Constant *getNSConcreteStackBlock();
   int getGlobalUniqueCount() { return ++Block.GlobalUniqueCount; }
   const llvm::Type *getBlockDescriptorType();
 





More information about the cfe-commits mailing list