[cfe-commits] r144318 - in /cfe/trunk: lib/CodeGen/CGObjCMac.cpp test/CodeGenObjC/selector-ref-invariance.m

Pete Cooper peter_cooper at apple.com
Thu Nov 10 13:45:06 PST 2011


Author: pete
Date: Thu Nov 10 15:45:06 2011
New Revision: 144318

URL: http://llvm.org/viewvc/llvm-project?rev=144318&view=rev
Log:
Add invariant.load metadata to loads from selector references.  Allows these loads to later be moved/combined in the optimizer.  Fixes <rdar://problem/6027699>

Added:
    cfe/trunk/test/CodeGenObjC/selector-ref-invariance.m
Modified:
    cfe/trunk/lib/CodeGen/CGObjCMac.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=144318&r1=144317&r2=144318&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Thu Nov 10 15:45:06 2011
@@ -5887,7 +5887,12 @@
 
   if (lval)
     return Entry;
-  return Builder.CreateLoad(Entry);
+  llvm::LoadInst* LI = Builder.CreateLoad(Entry);
+  
+  LI->setMetadata(CGM.getModule().getMDKindID("invariant.load"), 
+                  llvm::MDNode::get(VMContext,
+                                    ArrayRef<llvm::Value*>()));
+  return LI;
 }
 /// EmitObjCIvarAssign - Code gen for assigning to a __strong object.
 /// objc_assign_ivar (id src, id *dst, ptrdiff_t)

Added: cfe/trunk/test/CodeGenObjC/selector-ref-invariance.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/selector-ref-invariance.m?rev=144318&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/selector-ref-invariance.m (added)
+++ cfe/trunk/test/CodeGenObjC/selector-ref-invariance.m Thu Nov 10 15:45:06 2011
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -emit-llvm -fblocks -o - %s | FileCheck %s
+
+// rdar://6027699
+
+void test(id x) {
+// CHECK: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_", !invariant.load
+// CHECK: @objc_msgSend
+  [x foo];
+}





More information about the cfe-commits mailing list