]> granicus.if.org Git - clang/commitdiff
Move GlobalUniqueCount up into CGM.
authorMike Stump <mrs@apple.com>
Fri, 13 Feb 2009 18:36:05 +0000 (18:36 +0000)
committerMike Stump <mrs@apple.com>
Fri, 13 Feb 2009 18:36:05 +0000 (18:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64473 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGBlocks.cpp
lib/CodeGen/CodeGenModule.cpp
lib/CodeGen/CodeGenModule.h

index f61e0bcd39cd2fcc2b2a5534de14b0a318aa9a61..045f7338e005f3a367e0e6ea31f2533f6c7c4e38 100644 (file)
@@ -154,9 +154,7 @@ llvm::Constant *CodeGenFunction::BuildBlockLiteralTmp() {
   C = llvm::ConstantStruct::get(Elts);
 
   char Name[32];
-  // FIXME: Boost in CGM?
-  static int global_unique_count;
-  sprintf(Name, "__block_holder_tmp_%d", ++global_unique_count);
+  sprintf(Name, "__block_holder_tmp_%d", CGM.getGlobalUniqueCount());
   C = new llvm::GlobalVariable(C->getType(), true,
                                llvm::GlobalValue::InternalLinkage,
                                C, Name, &CGM.getModule());
index 53d99f07eb3723130277c2afeed94e797c105315..091158daba759d61414ee8c1a45936893615aa39 100644 (file)
@@ -49,7 +49,9 @@ CodeGenModule::CodeGenModule(ASTContext &C, const LangOptions &LO,
   }
 
   // If debug info generation is enabled, create the CGDebugInfo object.
-  DebugInfo = GenerateDebugInfo ? new CGDebugInfo(this) : 0;      
+  DebugInfo = GenerateDebugInfo ? new CGDebugInfo(this) : 0;
+
+  Block.GlobalUniqueCount = 0;
 }
 
 CodeGenModule::~CodeGenModule() {
index 4b1a06edc540a97fef77d7a1a30e083330980915..0d9caaa95d8f35d6f3db603a029e3c774fc0f27d 100644 (file)
@@ -129,6 +129,9 @@ class CodeGenModule {
   
   const llvm::Type *BlockDescriptorType;
   const llvm::Type * GenericBlockLiteralType;
+  struct {
+    int GlobalUniqueCount;
+  } Block;
 
   std::vector<llvm::Function *> BuiltinFunctions;
 public:
@@ -142,7 +145,7 @@ public:
   void Release();
 
   llvm::Constant *getNSConcreteGlobalBlock();
-
+  int getGlobalUniqueCount() { return ++Block.GlobalUniqueCount; }
   const llvm::Type *getBlockDescriptorType();
 
   const llvm::Type *getGenericBlockLiteralType();