summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2009-03-25 17:58:24 +0000
committerMike Stump <mrs@apple.com>2009-03-25 17:58:24 +0000
commitd2142cffbf0b34d9f7cd4e36539205c8f02ff7d2 (patch)
tree031d2e4aaae5cda49380cca070106dd2d0c1dd79 /clang/lib/CodeGen
parent12ef15f8b2473479e02dfc97b1a859358ba573ef (diff)
downloadbcm5719-llvm-d2142cffbf0b34d9f7cd4e36539205c8f02ff7d2.tar.gz
bcm5719-llvm-d2142cffbf0b34d9f7cd4e36539205c8f02ff7d2.zip
Fixup codegen for block literals that bleed copy/dispose information
from previous block literals. llvm-svn: 67696
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGBlocks.cpp15
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h3
2 files changed, 12 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index 5780fc2958f..eba741bc3c4 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -35,7 +35,8 @@ Enable__block("f__block",
llvm::cl::init(true));
llvm::Constant *CodeGenFunction::
-BuildDescriptorBlockDecl(uint64_t Size, const llvm::StructType* Ty,
+BuildDescriptorBlockDecl(bool BlockHasCopyDispose, uint64_t Size,
+ const llvm::StructType* Ty,
std::vector<HelperInfo> *NoteForHelper) {
const llvm::Type *UnsignedLongTy
= CGM.getTypes().ConvertType(getContext().UnsignedLongTy);
@@ -155,18 +156,20 @@ llvm::Value *CodeGenFunction::BuildBlockLiteralTmp(const BlockExpr *BE) {
// __invoke
uint64_t subBlockSize, subBlockAlign;
llvm::SmallVector<const Expr *, 8> subBlockDeclRefDecls;
+ bool subBlockHasCopyDispose = false;
llvm::Function *Fn
= CodeGenFunction(CGM).GenerateBlockFunction(BE, Info, CurFuncDecl, LocalDeclMap,
subBlockSize,
subBlockAlign,
subBlockDeclRefDecls,
- BlockHasCopyDispose);
+ subBlockHasCopyDispose);
+ BlockHasCopyDispose |= subBlockHasCopyDispose;
Elts[3] = Fn;
if (!Enable__block && BlockHasCopyDispose)
ErrorUnsupported(BE, "block literal that requires copy/dispose");
- if (BlockHasCopyDispose)
+ if (subBlockHasCopyDispose)
flags |= BLOCK_HAS_COPY_DISPOSE;
// __isa
@@ -186,7 +189,8 @@ llvm::Value *CodeGenFunction::BuildBlockLiteralTmp(const BlockExpr *BE) {
if (subBlockDeclRefDecls.size() == 0) {
// __descriptor
- Elts[4] = BuildDescriptorBlockDecl(subBlockSize, 0, 0);
+ assert(subBlockHasCopyDispose == false);
+ Elts[4] = BuildDescriptorBlockDecl(subBlockHasCopyDispose, subBlockSize, 0, 0);
// Optimize to being a global block.
Elts[0] = CGM.getNSConcreteGlobalBlock();
@@ -318,7 +322,8 @@ llvm::Value *CodeGenFunction::BuildBlockLiteralTmp(const BlockExpr *BE) {
NoteForHelper.resize(helpersize);
// __descriptor
- llvm::Value *Descriptor = BuildDescriptorBlockDecl(subBlockSize, Ty,
+ llvm::Value *Descriptor = BuildDescriptorBlockDecl(subBlockHasCopyDispose,
+ subBlockSize, Ty,
&NoteForHelper);
Descriptor = Builder.CreateBitCast(Descriptor, PtrToInt8Ty);
Builder.CreateStore(Descriptor, Builder.CreateStructGEP(V, 4, "block.tmp"));
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index acac86d8c2b..f850cfdc5bc 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -267,7 +267,8 @@ public:
//===--------------------------------------------------------------------===//
llvm::Value *BuildBlockLiteralTmp(const BlockExpr *);
- llvm::Constant *BuildDescriptorBlockDecl(uint64_t Size,
+ llvm::Constant *BuildDescriptorBlockDecl(bool BlockHasCopyDispose,
+ uint64_t Size,
const llvm::StructType *,
std::vector<HelperInfo> *);
OpenPOWER on IntegriCloud