summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGBlocks.cpp
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2009-03-06 04:53:30 +0000
committerMike Stump <mrs@apple.com>2009-03-06 04:53:30 +0000
commitfbe25dd1e4815eda2430a424181630620ce5085d (patch)
tree3375ece83b82840399809f5996c5ab3fc1192cdc /clang/lib/CodeGen/CGBlocks.cpp
parentd4a96730c1986b96f246fbc8df7adb5bcdbc4e4d (diff)
downloadbcm5719-llvm-fbe25dd1e4815eda2430a424181630620ce5085d.tar.gz
bcm5719-llvm-fbe25dd1e4815eda2430a424181630620ce5085d.zip
Finish off __Block_byref_id_object_dispose codegen for block literals.
llvm-svn: 66247
Diffstat (limited to 'clang/lib/CodeGen/CGBlocks.cpp')
-rw-r--r--clang/lib/CodeGen/CGBlocks.cpp31
1 files changed, 22 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index efb4e98e2d8..1c13f90fbff 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -793,7 +793,9 @@ llvm::Constant *BlockFunction::GeneratebyrefCopyHelperFunction() {
return llvm::ConstantExpr::getBitCast(Fn, PtrToInt8Ty);
}
-llvm::Constant *BlockFunction::GeneratebyrefDestroyHelperFunction() {
+llvm::Constant *
+BlockFunction::GeneratebyrefDestroyHelperFunction(const llvm::Type *T,
+ int flag) {
QualType R = getContext().VoidTy;
FunctionArgList Args;
@@ -825,7 +827,19 @@ llvm::Constant *BlockFunction::GeneratebyrefDestroyHelperFunction() {
FunctionDecl::Static, false,
true);
CGF.StartFunction(FD, R, Fn, Args, SourceLocation());
- // BuildBlockRelease(Src, flag);
+
+ llvm::Value *V = CGF.GetAddrOfLocalVar(Src);
+ V = Builder.CreateBitCast(V, T);
+ V = Builder.CreateStructGEP(V, 6, "x");
+ V = Builder.CreateBitCast(V, PtrToInt8Ty);
+
+ // FIXME: Move to other one.
+ // int flag = BLOCK_FIELD_IS_BYREF;
+ // FIXME: Add weak support
+ if (0)
+ flag |= BLOCK_FIELD_IS_WEAK;
+ flag |= BLOCK_BYREF_CALLER;
+ BuildBlockRelease(V, flag);
CGF.FinishFunction();
return llvm::ConstantExpr::getBitCast(Fn, PtrToInt8Ty);
@@ -835,8 +849,9 @@ llvm::Constant *BlockFunction::BuildbyrefCopyHelper(int flag) {
return CodeGenFunction(CGM).GeneratebyrefCopyHelperFunction();
}
-llvm::Constant *BlockFunction::BuildbyrefDestroyHelper(int flag) {
- return CodeGenFunction(CGM).GeneratebyrefDestroyHelperFunction();
+llvm::Constant *BlockFunction::BuildbyrefDestroyHelper(const llvm::Type *T,
+ int flag) {
+ return CodeGenFunction(CGM).GeneratebyrefDestroyHelperFunction(T, flag);
}
llvm::Value *BlockFunction::getBlockObjectDispose() {
@@ -853,13 +868,11 @@ llvm::Value *BlockFunction::getBlockObjectDispose() {
return CGM.BlockObjectDispose;
}
-void BlockFunction::BuildBlockRelease(llvm::Value *DeclPtr) {
+void BlockFunction::BuildBlockRelease(llvm::Value *V, int flag) {
llvm::Value *F = getBlockObjectDispose();
- llvm::Value *N, *V;
- V = Builder.CreateStructGEP(DeclPtr, 1, "forwarding");
- V = Builder.CreateLoad(V, false);
+ llvm::Value *N;
V = Builder.CreateBitCast(V, PtrToInt8Ty);
- N = llvm::ConstantInt::get(llvm::Type::Int32Ty, BLOCK_FIELD_IS_BYREF);
+ N = llvm::ConstantInt::get(llvm::Type::Int32Ty, flag);
Builder.CreateCall2(F, V, N);
}
OpenPOWER on IntegriCloud