aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/CGBlocks.cpp4
-rw-r--r--lib/CodeGen/CodeGenModule.cpp4
-rw-r--r--lib/CodeGen/CodeGenModule.h5
3 files changed, 8 insertions, 5 deletions
diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp
index f61e0bcd39..045f7338e0 100644
--- a/lib/CodeGen/CGBlocks.cpp
+++ b/lib/CodeGen/CGBlocks.cpp
@@ -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());
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 53d99f07eb..091158daba 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -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() {
diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h
index 4b1a06edc5..0d9caaa95d 100644
--- a/lib/CodeGen/CodeGenModule.h
+++ b/lib/CodeGen/CodeGenModule.h
@@ -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();