[cfe-commits] r66284 - in /cfe/trunk/lib/CodeGen: CGBlocks.cpp CGBlocks.h CodeGenFunction.h
Mike Stump
mrs at apple.com
Fri Mar 6 10:42:24 PST 2009
Author: mrs
Date: Fri Mar 6 12:42:23 2009
New Revision: 66284
URL: http://llvm.org/viewvc/llvm-project?rev=66284&view=rev
Log:
Pass the type of the block literal around to make required temporal ordering of code clearer.
Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGBlocks.h
cfe/trunk/lib/CodeGen/CodeGenFunction.h
Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=66284&r1=66283&r2=66284&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Fri Mar 6 12:42:23 2009
@@ -33,7 +33,8 @@
llvm::cl::ZeroOrMore,
llvm::cl::init(false));
-llvm::Constant *CodeGenFunction::BuildDescriptorBlockDecl(uint64_t Size) {
+llvm::Constant *CodeGenFunction::
+BuildDescriptorBlockDecl(uint64_t Size, const llvm::Type* Ty) {
const llvm::Type *UnsignedLongTy
= CGM.getTypes().ConvertType(getContext().UnsignedLongTy);
llvm::Constant *C;
@@ -52,10 +53,10 @@
if (BlockHasCopyDispose) {
// copy_func_helper_decl
- Elts.push_back(BuildCopyHelper());
+ Elts.push_back(BuildCopyHelper(Ty));
// destroy_func_decl
- Elts.push_back(BuildDestroyHelper());
+ Elts.push_back(BuildDestroyHelper(Ty));
}
C = llvm::ConstantStruct::get(Elts);
@@ -180,10 +181,10 @@
C = llvm::ConstantInt::get(IntTy, 0);
Elts[2] = C;
- // __descriptor
- Elts[4] = BuildDescriptorBlockDecl(subBlockSize);
-
if (subBlockDeclRefDecls.size() == 0) {
+ // __descriptor
+ Elts[4] = BuildDescriptorBlockDecl(subBlockSize, 0);
+
// Optimize to being a global block.
Elts[0] = CGM.getNSConcreteGlobalBlock();
Elts[1] = llvm::ConstantInt::get(IntTy, flags|BLOCK_IS_GLOBAL);
@@ -295,6 +296,9 @@
// FIXME: Ensure that the offset created by the backend for
// the struct matches the previously computed offset in BlockDecls.
}
+
+ // __descriptor
+ Elts[4] = BuildDescriptorBlockDecl(subBlockSize, Ty);
}
QualType BPT = BE->getType();
@@ -671,7 +675,7 @@
return BlockOffset-Size;
}
-llvm::Constant *BlockFunction::GenerateCopyHelperFunction() {
+llvm::Constant *BlockFunction::GenerateCopyHelperFunction(const llvm::Type *Ty) {
QualType R = getContext().VoidTy;
FunctionArgList Args;
@@ -709,7 +713,8 @@
return llvm::ConstantExpr::getBitCast(Fn, PtrToInt8Ty);
}
-llvm::Constant *BlockFunction::GenerateDestroyHelperFunction() {
+llvm::Constant *BlockFunction::
+GenerateDestroyHelperFunction(const llvm::Type* Ty) {
QualType R = getContext().VoidTy;
FunctionArgList Args;
@@ -747,12 +752,12 @@
return llvm::ConstantExpr::getBitCast(Fn, PtrToInt8Ty);
}
-llvm::Constant *BlockFunction::BuildCopyHelper() {
- return CodeGenFunction(CGM).GenerateCopyHelperFunction();
+llvm::Constant *BlockFunction::BuildCopyHelper(const llvm::Type *Ty) {
+ return CodeGenFunction(CGM).GenerateCopyHelperFunction(Ty);
}
-llvm::Constant *BlockFunction::BuildDestroyHelper() {
- return CodeGenFunction(CGM).GenerateDestroyHelperFunction();
+llvm::Constant *BlockFunction::BuildDestroyHelper(const llvm::Type *Ty) {
+ return CodeGenFunction(CGM).GenerateDestroyHelperFunction(Ty);
}
llvm::Constant *BlockFunction::
Modified: cfe/trunk/lib/CodeGen/CGBlocks.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.h?rev=66284&r1=66283&r2=66284&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.h (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.h Fri Mar 6 12:42:23 2009
@@ -158,11 +158,11 @@
ImplicitParamDecl *BlockStructDecl;
ImplicitParamDecl *getBlockStructDecl() { return BlockStructDecl; }
- llvm::Constant *GenerateCopyHelperFunction();
- llvm::Constant *GenerateDestroyHelperFunction();
+ llvm::Constant *GenerateCopyHelperFunction(const llvm::Type *);
+ llvm::Constant *GenerateDestroyHelperFunction(const llvm::Type *);
- llvm::Constant *BuildCopyHelper();
- llvm::Constant *BuildDestroyHelper();
+ llvm::Constant *BuildCopyHelper(const llvm::Type *);
+ llvm::Constant *BuildDestroyHelper(const llvm::Type *);
llvm::Constant *GeneratebyrefCopyHelperFunction(const llvm::Type *, int flag);
llvm::Constant *GeneratebyrefDestroyHelperFunction(const llvm::Type *T, int);
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=66284&r1=66283&r2=66284&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Fri Mar 6 12:42:23 2009
@@ -266,7 +266,7 @@
//===--------------------------------------------------------------------===//
llvm::Value *BuildBlockLiteralTmp(const BlockExpr *);
- llvm::Constant *BuildDescriptorBlockDecl(uint64_t Size);
+ llvm::Constant *BuildDescriptorBlockDecl(uint64_t Size, const llvm::Type *);
llvm::Function *GenerateBlockFunction(const BlockExpr *BExpr,
const BlockInfo& Info,
More information about the cfe-commits
mailing list