[cfe-commits] r136949 - in /cfe/trunk: lib/CodeGen/CGObjC.cpp test/CodeGenObjC/arc-foreach.m
John McCall
rjmccall at apple.com
Thu Aug 4 17:14:38 PDT 2011
Author: rjmccall
Date: Thu Aug 4 19:14:38 2011
New Revision: 136949
URL: http://llvm.org/viewvc/llvm-project?rev=136949&view=rev
Log:
The continue label in an ARC for-in loop should not involve
releasing the collection.
Modified:
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/test/CodeGenObjC/arc-foreach.m
Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=136949&r1=136948&r2=136949&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Thu Aug 4 19:14:38 2011
@@ -995,7 +995,6 @@
variable = EmitAutoVarAlloca(*cast<VarDecl>(SD->getSingleDecl()));
JumpDest LoopEnd = getJumpDestInCurrentScope("forcoll.end");
- JumpDest AfterBody = getJumpDestInCurrentScope("forcoll.next");
// Fast enumeration state.
QualType StateTy = getContext().getObjCFastEnumerationStateType();
@@ -1031,6 +1030,10 @@
Collection = EmitScalarExpr(S.getCollection());
}
+ // The 'continue' label needs to appear within the cleanup for the
+ // collection object.
+ JumpDest AfterBody = getJumpDestInCurrentScope("forcoll.next");
+
// Send it our message:
CallArgList Args;
Modified: cfe/trunk/test/CodeGenObjC/arc-foreach.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-foreach.m?rev=136949&r1=136948&r2=136949&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/arc-foreach.m (original)
+++ cfe/trunk/test/CodeGenObjC/arc-foreach.m Thu Aug 4 19:14:38 2011
@@ -148,3 +148,24 @@
// This bitcast is for the final release.
// CHECK-LP64: [[T0:%.*]] = bitcast [[ARRAY_T]]* [[COLL]] to i8*
// CHECK-LP64-NEXT: call void @objc_release(i8* [[T0]])
+
+
+// Check that the 'continue' label is positioned appropriately
+// relative to the collection clenaup.
+void test3(NSArray *array) {
+ for (id x in array) {
+ if (!x) continue;
+ use(x);
+ }
+
+ // CHECK-LP64: define void @test3(
+ // CHECK-LP64: [[ARRAY:%.*]] = alloca [[ARRAY_T]]*, align 8
+ // CHECK-LP64-NEXT: [[X:%.*]] = alloca i8*, align 8
+ // CHECK-LP64: [[T0:%.*]] = load i8** [[X]], align 8
+ // CHECK-LP64-NEXT: [[T1:%.*]] = icmp ne i8* [[T0]], null
+ // CHECK-LP64-NEXT: br i1 [[T1]],
+ // CHECK-LP64: br label [[L:%[^ ]+]]
+ // CHECK-LP64: [[T0:%.*]] = load i8** [[X]], align 8
+ // CHECK-LP64-NEXT: call void @use(i8* [[T0]])
+ // CHECK-LP64-NEXT: br label [[L]]
+}
More information about the cfe-commits
mailing list