phunix/external/bsd/llvm/dist/clang/test/CodeGenObjC/optimize-ivar-offset-load.m
Lionel Sambuc 0a6a1f1d05 NetBSD re-synchronization of the source tree
This brings our tree to NetBSD 7.0, as found on -current on the
10-10-2015.

This updates:
 - LLVM to 3.6.1
 - GCC to GCC 5.1
 - Replace minix/commands/zdump with usr.bin/zdump
 - external/bsd/libelf has moved to /external/bsd/elftoolchain/
 - Import ctwm
 - Drop sprintf from libminc

Change-Id: I149836ac18e9326be9353958bab9b266efb056f0
2016-01-13 20:32:14 +01:00

65 lines
1.7 KiB
Objective-C

// 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** @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** @OBJC_SELECTOR_REFERENCES_, align 8, !invariant.load
// CHECK: [[IVAR:%.*]] = load i64* @"OBJC_IVAR_$_SampleClass._value", align 8, !invariant.load