Move GlobalUniqueCount up into CGM.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64473 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp
index f61e0bc..045f733 100644
--- a/lib/CodeGen/CGBlocks.cpp
+++ b/lib/CodeGen/CGBlocks.cpp
@@ -154,9 +154,7 @@
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());
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 53d99f0..091158d 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -49,7 +49,9 @@
}
// 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() {
diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h
index 4b1a06e..0d9caaa 100644
--- a/lib/CodeGen/CodeGenModule.h
+++ b/lib/CodeGen/CodeGenModule.h
@@ -129,6 +129,9 @@
const llvm::Type *BlockDescriptorType;
const llvm::Type * GenericBlockLiteralType;
+ struct {
+ int GlobalUniqueCount;
+ } Block;
std::vector<llvm::Function *> BuiltinFunctions;
public:
@@ -142,7 +145,7 @@
void Release();
llvm::Constant *getNSConcreteGlobalBlock();
-
+ int getGlobalUniqueCount() { return ++Block.GlobalUniqueCount; }
const llvm::Type *getBlockDescriptorType();
const llvm::Type *getGenericBlockLiteralType();