[cfe-commits] r133861 - in /cfe/trunk: lib/CodeGen/CGObjC.cpp test/CodeGenObjCXX/arc-move.mm

John McCall rjmccall at apple.com
Fri Jun 24 19:26:44 PDT 2011


Author: rjmccall
Date: Fri Jun 24 21:26:44 2011
New Revision: 133861

URL: http://llvm.org/viewvc/llvm-project?rev=133861&view=rev
Log:
Do not apply the ARC move optimization to 'const'-qualified xvalues.


Modified:
    cfe/trunk/lib/CodeGen/CGObjC.cpp
    cfe/trunk/test/CodeGenObjCXX/arc-move.mm

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=133861&r1=133860&r2=133861&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Fri Jun 24 21:26:44 2011
@@ -2269,7 +2269,7 @@
   // If we're loading retained from a __strong xvalue, we can avoid 
   // an extra retain/release pair by zeroing out the source of this
   // "move" operation.
-  if (e->isXValue() &&
+  if (e->isXValue() && !e->getType().isConstQualified() &&
       e->getType().getObjCLifetime() == Qualifiers::OCL_Strong) {
     // Emit the lvalue
     LValue lv = CGF.EmitLValue(e);

Modified: cfe/trunk/test/CodeGenObjCXX/arc-move.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/arc-move.mm?rev=133861&r1=133860&r2=133861&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjCXX/arc-move.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/arc-move.mm Fri Jun 24 21:26:44 2011
@@ -61,3 +61,15 @@
   // CHECK-NEXT: call void @objc_release(i8* [[OBJ]])
   // CHECK-NEXT: ret void
 }
+
+// CHECK: define void @_Z10const_moveRKU8__strongP11objc_object(
+void const_move(const __strong id &x) {
+  // CHECK:      [[Y:%.*]] = alloca i8*,
+  // CHECK:      [[X:%.*]] = call i8** @_Z4moveIRKU8__strongP11objc_objectEON16remove_referenceIT_E4typeEOS5_(
+  // CHECK-NEXT: [[T0:%.*]] = load i8** [[X]]
+  // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retain(i8* [[T0]])
+  // CHECK-NEXT: store i8* [[T1]], i8** [[Y]]
+  // CHECK-NEXT: [[T0:%.*]] = load i8** [[Y]]
+  // CHECK-NEXT: call void @objc_release(i8* [[T0]])
+  id y = move(x);
+}





More information about the cfe-commits mailing list