aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGBlocks.cpp
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2009-03-13 23:34:28 +0000
committerMike Stump <mrs@apple.com>2009-03-13 23:34:28 +0000
commit7f28a9c37e67ae16396042ad9c085830969daf29 (patch)
tree95370084f60e66ae83ba7de718898599418c9e4a /lib/CodeGen/CGBlocks.cpp
parentad5f960f9e42568a87bf5e03dce7ad878f9ba6da (diff)
Do up codegen for function static data and externs in functions in block
literals. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66984 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGBlocks.cpp')
-rw-r--r--lib/CodeGen/CGBlocks.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp
index a876938c02..fcda90794e 100644
--- a/lib/CodeGen/CGBlocks.cpp
+++ b/lib/CodeGen/CGBlocks.cpp
@@ -155,7 +155,8 @@ llvm::Value *CodeGenFunction::BuildBlockLiteralTmp(const BlockExpr *BE) {
uint64_t subBlockSize, subBlockAlign;
llvm::SmallVector<const Expr *, 8> subBlockDeclRefDecls;
llvm::Function *Fn
- = CodeGenFunction(CGM).GenerateBlockFunction(BE, Info, subBlockSize,
+ = CodeGenFunction(CGM).GenerateBlockFunction(BE, Info, LocalDeclMap,
+ subBlockSize,
subBlockAlign,
subBlockDeclRefDecls,
BlockHasCopyDispose);
@@ -558,8 +559,10 @@ BlockModule::GetAddrOfGlobalBlock(const BlockExpr *BE, const char * n) {
uint64_t subBlockSize, subBlockAlign;
llvm::SmallVector<const Expr *, 8> subBlockDeclRefDecls;
bool subBlockHasCopyDispose = false;
+ llvm::DenseMap<const Decl*, llvm::Value*> LocalDeclMap;
llvm::Function *Fn
- = CodeGenFunction(CGM).GenerateBlockFunction(BE, Info, subBlockSize,
+ = CodeGenFunction(CGM).GenerateBlockFunction(BE, Info, LocalDeclMap,
+ subBlockSize,
subBlockAlign,
subBlockDeclRefDecls,
subBlockHasCopyDispose);
@@ -602,10 +605,24 @@ llvm::Value *CodeGenFunction::LoadBlockStruct() {
llvm::Function *
CodeGenFunction::GenerateBlockFunction(const BlockExpr *BExpr,
const BlockInfo& Info,
+ llvm::DenseMap<const Decl*, llvm::Value*> ldm,
uint64_t &Size,
uint64_t &Align,
llvm::SmallVector<const Expr *, 8> &subBlockDeclRefDecls,
bool &subBlockHasCopyDispose) {
+ // Arrange for local static and local extern declarations to appear
+ // to be local to this function as well, as they are directly referenced
+ // in a block.
+ for (llvm::DenseMap<const Decl *, llvm::Value*>::iterator i = ldm.begin();
+ i != ldm.end();
+ ++i) {
+ const VarDecl *VD = dyn_cast<VarDecl>(i->first);
+
+ if (VD->getStorageClass() == VarDecl::Static
+ || VD->getStorageClass() == VarDecl::Extern)
+ LocalDeclMap[VD] = i->second;
+ }
+
const FunctionProtoType *FTy =
cast<FunctionProtoType>(BExpr->getFunctionType());