diff options
author | Mike Stump <mrs@apple.com> | 2009-02-13 19:29:27 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2009-02-13 19:29:27 +0000 |
commit | 59c5b118dfbcbc22c65ae42b8f5ef5979ec802ee (patch) | |
tree | c2af1a69d8a16c62ef8af8d61bee42545af7fbf1 /lib/CodeGen/CGBlocks.cpp | |
parent | b805dad4aa386aeae0f72512895bd238678d37a5 (diff) |
Move NSConcreteStackBlock into CGM.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64479 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGBlocks.cpp')
-rw-r--r-- | lib/CodeGen/CGBlocks.cpp | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp index be79a1a1ac..d6c248dcef 100644 --- a/lib/CodeGen/CGBlocks.cpp +++ b/lib/CodeGen/CGBlocks.cpp @@ -93,6 +93,24 @@ llvm::Constant *CodeGenModule::getNSConcreteGlobalBlock() { 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 @@ llvm::Constant *CodeGenFunction::BuildBlockLiteralTmp() { 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); |