[cfe-commits] r127725 - in /cfe/trunk: lib/CodeGen/CGExprScalar.cpp test/CodeGenObjC/blocks.m
John McCall
rjmccall at apple.com
Tue Mar 15 19:53:38 PDT 2011
Author: rjmccall
Date: Tue Mar 15 21:53:38 2011
New Revision: 127725
URL: http://llvm.org/viewvc/llvm-project?rev=127725&view=rev
Log:
Don't emit read barriers for reading __weak __block variables
in non-GC mode.
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/test/CodeGenObjC/blocks.m
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=127725&r1=127724&r2=127725&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Tue Mar 15 21:53:38 2011
@@ -1221,10 +1221,8 @@
}
Value *ScalarExprEmitter::VisitBlockDeclRefExpr(const BlockDeclRefExpr *E) {
- llvm::Value *V = CGF.GetAddrOfBlockDecl(E);
- if (E->getType().isObjCGCWeak())
- return CGF.CGM.getObjCRuntime().EmitObjCWeakRead(CGF, V);
- return CGF.EmitLoadOfScalar(V, false, 0, E->getType());
+ LValue LV = CGF.EmitBlockDeclRefLValue(E);
+ return CGF.EmitLoadOfLValue(LV, E->getType()).getScalarVal();
}
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/test/CodeGenObjC/blocks.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/blocks.m?rev=127725&r1=127724&r2=127725&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/blocks.m (original)
+++ cfe/trunk/test/CodeGenObjC/blocks.m Tue Mar 15 21:53:38 2011
@@ -87,3 +87,16 @@
__weak __block Test2 *weakX = x;
test2_helper(^{ [weakX destroy]; });
}
+
+// rdar://problem/9124263
+// In the test above, check that the use in the invocation function
+// doesn't require a read barrier.
+// CHECK: define internal void @__test2_block_invoke_
+// CHECK: [[BLOCK:%.*]] = bitcast i8* {{%.*}} to [[BLOCK_T]]*
+// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+// CHECK-NEXT: [[T1:%.*]] = load i8** [[T0]]
+// CHECK-NEXT: [[T2:%.*]] = bitcast i8* [[T1]] to [[WEAK_T]]*
+// CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds [[WEAK_T]]* [[T2]], i32 0, i32 1
+// CHECK-NEXT: [[T4:%.*]] = load [[WEAK_T]]** [[T3]]
+// CHECK-NEXT: [[WEAKX:%.*]] = getelementptr inbounds [[WEAK_T]]* [[T4]], i32 0, i32 6
+// CHECK-NEXT: [[T0:%.*]] = load [[TEST2]]** [[WEAKX]], align 4
More information about the cfe-commits
mailing list