diff options
author | John McCall <rjmccall@apple.com> | 2011-02-22 22:38:33 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-02-22 22:38:33 +0000 |
commit | 8178df3b39ab923ff5d24538812628abee33df79 (patch) | |
tree | c9d1d021b1edf10550dd705dc5a69d2b9814846a /lib/CodeGen/CGBlocks.cpp | |
parent | 201e519ad9cc2863bc94cf799e407a81ed29181f (diff) |
Emit the structure layout of the block literal parameter to a block
invocation function into the debug info. Rather than faking up a class,
which is tricky because of the custom layout we do, we just emit a struct
directly from the layout information we've already got.
Also, don't emit an unnecessarily parameter alloca for this "variable".
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126255 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGBlocks.cpp')
-rw-r--r-- | lib/CodeGen/CGBlocks.cpp | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp index 83cca931ce..9587de223a 100644 --- a/lib/CodeGen/CGBlocks.cpp +++ b/lib/CodeGen/CGBlocks.cpp @@ -895,12 +895,9 @@ CodeGenFunction::GenerateBlockFunction(GlobalDecl GD, QualType selfTy = getContext().VoidPtrTy; IdentifierInfo *II = &CGM.getContext().Idents.get(".block_descriptor"); - // FIXME: this leaks, and we only need it very temporarily. - ImplicitParamDecl *selfDecl = - ImplicitParamDecl::Create(getContext(), - const_cast<BlockDecl*>(blockDecl), - SourceLocation(), II, selfTy); - args.push_back(std::make_pair(selfDecl, selfTy)); + ImplicitParamDecl selfDecl(const_cast<BlockDecl*>(blockDecl), + SourceLocation(), II, selfTy); + args.push_back(std::make_pair(&selfDecl, selfTy)); // Now add the rest of the parameters. for (BlockDecl::param_const_iterator i = blockDecl->param_begin(), @@ -928,12 +925,11 @@ CodeGenFunction::GenerateBlockFunction(GlobalDecl GD, blockInfo.getBlockExpr()->getBody()->getLocEnd()); CurFuncDecl = outerFnDecl; // StartFunction sets this to blockDecl - // Okay. Undo some of what StartFunction did. We really don't need - // an alloca for the block address; in theory we could remove it, - // but that might do unpleasant things to debug info. - llvm::AllocaInst *blockAddrAlloca - = cast<llvm::AllocaInst>(LocalDeclMap[selfDecl]); - llvm::Value *blockAddr = Builder.CreateLoad(blockAddrAlloca); + // Okay. Undo some of what StartFunction did. + + // Pull the 'self' reference out of the local decl map. + llvm::Value *blockAddr = LocalDeclMap[&selfDecl]; + LocalDeclMap.erase(&selfDecl); BlockPointer = Builder.CreateBitCast(blockAddr, blockInfo.StructureType->getPointerTo(), "block"); @@ -1010,7 +1006,7 @@ CodeGenFunction::GenerateBlockFunction(GlobalDecl GD, continue; } - DI->EmitDeclareOfBlockDeclRefVariable(variable, blockAddrAlloca, + DI->EmitDeclareOfBlockDeclRefVariable(variable, BlockPointer, Builder, blockInfo); } } |