[cfe-commits] r113675 - in /cfe/trunk: lib/CodeGen/CGBlocks.cpp lib/CodeGen/CGObjCGNU.cpp lib/CodeGen/CGObjCMac.cpp lib/CodeGen/CGObjCRuntime.h test/CodeGenObjC/block-var-layout.m
Fariborz Jahanian
fjahanian at apple.com
Fri Sep 10 18:27:29 PDT 2010
Author: fjahanian
Date: Fri Sep 10 20:27:29 2010
New Revision: 113675
URL: http://llvm.org/viewvc/llvm-project?rev=113675&view=rev
Log:
Fixes an obscure bug in importd block variable layout
information when imported variable is used
more than once. Originally though to be a bug in importing
block varibles. Fixes radar 8417746.
Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CGObjCRuntime.h
cfe/trunk/test/CodeGenObjC/block-var-layout.m
Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=113675&r1=113674&r2=113675&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Fri Sep 10 20:27:29 2010
@@ -757,7 +757,7 @@
// Capture block layout info. here.
if (CGM.getContext().getLangOptions().ObjC1)
- BlockVarLayout = CGM.getObjCRuntime().GCBlockLayout(*this, Info.DeclRefs);
+ BlockVarLayout = CGM.getObjCRuntime().GCBlockLayout(*this, BlockLayout);
else
BlockVarLayout = llvm::Constant::getNullValue(PtrToInt8Ty);
Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=113675&r1=113674&r2=113675&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Fri Sep 10 20:27:29 2010
@@ -213,7 +213,7 @@
const ObjCInterfaceDecl *Interface,
const ObjCIvarDecl *Ivar);
virtual llvm::Constant *GCBlockLayout(CodeGen::CodeGenFunction &CGF,
- const llvm::SmallVectorImpl<const BlockDeclRefExpr *> &) {
+ const llvm::SmallVectorImpl<const Expr *> &) {
return NULLPtr;
}
};
Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=113675&r1=113674&r2=113675&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Fri Sep 10 20:27:29 2010
@@ -1000,7 +1000,7 @@
/// definition is seen. The return value has type ProtocolPtrTy.
virtual llvm::Constant *GetOrEmitProtocolRef(const ObjCProtocolDecl *PD)=0;
virtual llvm::Constant *GCBlockLayout(CodeGen::CodeGenFunction &CGF,
- const llvm::SmallVectorImpl<const BlockDeclRefExpr *> &);
+ const llvm::SmallVectorImpl<const Expr *> &);
};
@@ -1663,11 +1663,11 @@
}
llvm::Constant *CGObjCCommonMac::GCBlockLayout(CodeGen::CodeGenFunction &CGF,
- const llvm::SmallVectorImpl<const BlockDeclRefExpr *> &DeclRefs) {
+ const llvm::SmallVectorImpl<const Expr *> &BlockLayout) {
llvm::Constant *NullPtr =
llvm::Constant::getNullValue(llvm::Type::getInt8PtrTy(VMContext));
if ((CGM.getLangOptions().getGCMode() == LangOptions::NonGC) ||
- DeclRefs.empty())
+ BlockLayout.empty())
return NullPtr;
bool hasUnion = false;
SkipIvars.clear();
@@ -1678,8 +1678,11 @@
// __isa is the first field in block descriptor and must assume by runtime's
// convention that it is GC'able.
IvarsInfo.push_back(GC_IVAR(0, 1));
- for (size_t i = 0; i < DeclRefs.size(); ++i) {
- const BlockDeclRefExpr *BDRE = DeclRefs[i];
+ for (size_t i = 0; i < BlockLayout.size(); ++i) {
+ const Expr *E = BlockLayout[i];
+ const BlockDeclRefExpr *BDRE = dyn_cast<BlockDeclRefExpr>(E);
+ if (!BDRE)
+ continue;
const ValueDecl *VD = BDRE->getDecl();
CharUnits Offset = CGF.BlockDecls[VD];
uint64_t FieldOffset = Offset.getQuantity();
Modified: cfe/trunk/lib/CodeGen/CGObjCRuntime.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCRuntime.h?rev=113675&r1=113674&r2=113675&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGObjCRuntime.h Fri Sep 10 20:27:29 2010
@@ -220,7 +220,7 @@
llvm::Value *SrcPtr,
llvm::Value *Size) = 0;
virtual llvm::Constant *GCBlockLayout(CodeGen::CodeGenFunction &CGF,
- const llvm::SmallVectorImpl<const BlockDeclRefExpr *> &) = 0;
+ const llvm::SmallVectorImpl<const Expr *> &) = 0;
};
Modified: cfe/trunk/test/CodeGenObjC/block-var-layout.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/block-var-layout.m?rev=113675&r1=113674&r2=113675&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/block-var-layout.m (original)
+++ cfe/trunk/test/CodeGenObjC/block-var-layout.m Fri Sep 10 20:27:29 2010
@@ -107,6 +107,23 @@
}
+// rdar: //8417746
+void CFRelease(id);
+void notifyBlock(id dependentBlock) {
+ id singleObservationToken;
+ id token;
+ void (^b)();
+ void (^wrapperBlock)() = ^() {
+ CFRelease(singleObservationToken);
+ CFRelease(singleObservationToken);
+ CFRelease(token);
+ CFRelease(singleObservationToken);
+ b();
+ };
+ wrapperBlock();
+}
+
+
// CHECK-LP64: L_OBJC_CLASS_NAME_:
// CHECK-LP64-NEXT: .asciz "\0011\024"
@@ -121,3 +138,6 @@
// CHECK-LP64: L_OBJC_CLASS_NAME_14:
// CHECK-LP64-NEXT: .asciz "\001A\021\022p"
+
+// CHECK-LP64: L_OBJC_CLASS_NAME_16:
+// CHECK-LP64-NEXT: .asciz "\0013"
More information about the cfe-commits
mailing list