[cfe-commits] r150994 - in /cfe/trunk: lib/CodeGen/CGObjCMac.cpp test/CodeGenObjC/ivar-base-as-invariant-load.m
Fariborz Jahanian
fjahanian at apple.com
Mon Feb 20 14:42:22 PST 2012
Author: fjahanian
Date: Mon Feb 20 16:42:22 2012
New Revision: 150994
URL: http://llvm.org/viewvc/llvm-project?rev=150994&view=rev
Log:
objc IRGen: force CSE of load of ivar offsets by setting
the 'invariant.load' metadata tag onto those loads.
// rdar://10840980
Added:
cfe/trunk/test/CodeGenObjC/ivar-base-as-invariant-load.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=150994&r1=150993&r2=150994&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Mon Feb 20 16:42:22 2012
@@ -5704,8 +5704,13 @@
const ObjCIvarDecl *Ivar,
unsigned CVRQualifiers) {
ObjCInterfaceDecl *ID = ObjectTy->getAs<ObjCObjectType>()->getInterface();
+ llvm::Value *Offset = EmitIvarOffset(CGF, ID, Ivar);
+ if (llvm::LoadInst *LI = dyn_cast<llvm::LoadInst>(Offset))
+ LI->setMetadata(CGM.getModule().getMDKindID("invariant.load"),
+ llvm::MDNode::get(VMContext,
+ ArrayRef<llvm::Value*>()));
return EmitValueForIvarAtOffset(CGF, ID, BaseValue, Ivar, CVRQualifiers,
- EmitIvarOffset(CGF, ID, Ivar));
+ Offset);
}
llvm::Value *CGObjCNonFragileABIMac::EmitIvarOffset(
Added: cfe/trunk/test/CodeGenObjC/ivar-base-as-invariant-load.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/ivar-base-as-invariant-load.m?rev=150994&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/ivar-base-as-invariant-load.m (added)
+++ cfe/trunk/test/CodeGenObjC/ivar-base-as-invariant-load.m Mon Feb 20 16:42:22 2012
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin -x objective-c %s -o - | FileCheck %s
+// rdar://10840980
+
+ at interface A {
+ struct {
+ unsigned char a : 1;
+ unsigned char b : 1;
+ unsigned char c : 1;
+ } _flags;
+}
+
+ at end
+
+ at implementation A
+
+- (id)init {
+ _flags.a = 1;
+ _flags.b = 1;
+ _flags.c = 1;
+
+ return self;
+}
+
+ at end
+
+// CHECK: [[T1:%.*]] = load i64* @"OBJC_IVAR_$_A._flags", !invariant.load !4
+// CHECK: [[T2:%.*]] = load i64* @"OBJC_IVAR_$_A._flags", !invariant.load !4
+// CHECK: [[T3:%.*]] = load i64* @"OBJC_IVAR_$_A._flags", !invariant.load !4
+
More information about the cfe-commits
mailing list