diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2014-03-04 18:34:52 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2014-03-04 18:34:52 +0000 |
| commit | dafffbe2beb7e69aacb9c73a9ea173bb2563867d (patch) | |
| tree | 68a2cc9e8236a5cbb75b92523839450d53f13ac5 /clang/test | |
| parent | b8322b13f84e2291ce0d5ebe1fbaf9a2af3ac477 (diff) | |
| download | bcm5719-llvm-dafffbe2beb7e69aacb9c73a9ea173bb2563867d.tar.gz bcm5719-llvm-dafffbe2beb7e69aacb9c73a9ea173bb2563867d.zip | |
Objective-C IRGen. Fix up the hueristics for determining
if an ivar offset load is invariant iff inside an instance method
and ivar belongs to instance method's class and one of its super class.
// rdar://16095748
llvm-svn: 202872
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/CodeGenObjC/optimize-ivar-offset-load.m | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/clang/test/CodeGenObjC/optimize-ivar-offset-load.m b/clang/test/CodeGenObjC/optimize-ivar-offset-load.m new file mode 100644 index 00000000000..d34ac137587 --- /dev/null +++ b/clang/test/CodeGenObjC/optimize-ivar-offset-load.m @@ -0,0 +1,64 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Os -emit-llvm %s -o - | FileCheck %s +// rdar://16095748 + +@interface NSObject +@end + +@interface SampleClass : NSObject { + @public + int _value; +} ++ (SampleClass*) new; +@end + +@interface AppDelegate : NSObject +@end + +extern void foo(int); + +@implementation AppDelegate +- (void)application +{ + // Create set of objects in loop + for(int i = 0; i < 2; i++) { + SampleClass *sample = [SampleClass new]; + foo (sample->_value); + } +} +@end +// CHECK: [[IVAR:%.*]] = load i64* @"OBJC_IVAR_$_SampleClass._value", align 8 +// CHECK: [[THREE:%.*]] = bitcast [[ONE:%.*]]* [[CALL:%.*]] to i8* +// CHECK: [[ADDPTR:%.*]] = getelementptr inbounds i8* [[THREE]], i64 [[IVAR]] +// CHECK: [[FOUR:%.*]] = bitcast i8* [[ADDPTR]] to i32* +// CHECK: [[FIVE:%.*]] = load i32* [[FOUR]], align 4 +// CHECK: tail call void @foo(i32 [[FIVE]]) + +@implementation SampleClass ++ (SampleClass*) new { return 0; } +- (void) SampleClassApplication +{ + // Create set of objects in loop + for(int i = 0; i < 2; i++) { + SampleClass *sample = [SampleClass new]; + foo (sample->_value); + } +} +@end +// CHECK: [[ZERO:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_", align 8, !invariant.load +// CHECK: [[IVAR:%.*]] = load i64* @"OBJC_IVAR_$_SampleClass._value", align 8, !invariant.load + +@interface Sample : SampleClass @end + +@implementation Sample +- (void) SampleApplication +{ + // Create set of objects in loop + for(int i = 0; i < 2; i++) { + SampleClass *sample = [SampleClass new]; + foo (sample->_value); + } +} +@end +// CHECK: [[ZERO:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_", align 8, !invariant.load +// CHECK: [[IVAR:%.*]] = load i64* @"OBJC_IVAR_$_SampleClass._value", align 8, !invariant.load + |

