aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGBlocks.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-09-12 02:14:24 +0000
committerAnders Carlsson <andersca@mac.com>2009-09-12 02:14:24 +0000
commit7dfa4079f4b37507048b19bfc693d3b015d9dd11 (patch)
treee48439e93568304b8ed630f857e958ca62951268 /lib/CodeGen/CGBlocks.cpp
parent5e7bacef79f7725f4abc45e2a5eccedae40dfcd3 (diff)
For __block variables, cache the LLVM types as well as which LLVM field where the variable is stored.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81599 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGBlocks.cpp')
-rw-r--r--lib/CodeGen/CGBlocks.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp
index 43b098e021..b8827793d6 100644
--- a/lib/CodeGen/CGBlocks.cpp
+++ b/lib/CodeGen/CGBlocks.cpp
@@ -442,10 +442,10 @@ RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E) {
}
llvm::Value *CodeGenFunction::GetAddrOfBlockDecl(const BlockDeclRefExpr *E) {
- uint64_t &offset = BlockDecls[E->getDecl()];
+ const ValueDecl *VD = E->getDecl();
+
+ uint64_t &offset = BlockDecls[VD];
- const llvm::Type *Ty;
- Ty = CGM.getTypes().ConvertType(E->getDecl()->getType());
// See if we have already allocated an offset for this variable.
if (offset == 0) {
@@ -462,20 +462,23 @@ llvm::Value *CodeGenFunction::GetAddrOfBlockDecl(const BlockDeclRefExpr *E) {
offset),
"block.literal");
if (E->isByRef()) {
- bool needsCopyDispose = BlockRequiresCopying(E->getType());
const llvm::Type *PtrStructTy
- = llvm::PointerType::get(BuildByRefType(E->getDecl()), 0);
+ = llvm::PointerType::get(BuildByRefType(VD), 0);
// The block literal will need a copy/destroy helper.
BlockHasCopyDispose = true;
- Ty = PtrStructTy;
+
+ const llvm::Type *Ty = PtrStructTy;
Ty = llvm::PointerType::get(Ty, 0);
V = Builder.CreateBitCast(V, Ty);
V = Builder.CreateLoad(V, false);
V = Builder.CreateStructGEP(V, 1, "forwarding");
V = Builder.CreateLoad(V, false);
V = Builder.CreateBitCast(V, PtrStructTy);
- V = Builder.CreateStructGEP(V, needsCopyDispose*2 + 4, "x");
+ V = Builder.CreateStructGEP(V, getByRefValueLLVMField(VD),
+ VD->getNameAsString());
} else {
+ const llvm::Type *Ty = CGM.getTypes().ConvertType(VD->getType());
+
Ty = llvm::PointerType::get(Ty, 0);
V = Builder.CreateBitCast(V, Ty);
}