| 1 |
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -O0 -emit-llvm %s -o - | FileCheck %s |
| 2 |
|
| 3 |
@interface MyNSObject |
| 4 |
@end |
| 5 |
|
| 6 |
@interface SampleClass : MyNSObject { |
| 7 |
@public |
| 8 |
int _value; |
| 9 |
} |
| 10 |
+ (SampleClass*) new; |
| 11 |
@end |
| 12 |
|
| 13 |
@interface AppDelegate : MyNSObject |
| 14 |
@end |
| 15 |
|
| 16 |
extern void foo(int); |
| 17 |
|
| 18 |
@implementation AppDelegate |
| 19 |
- (void)application |
| 20 |
{ |
| 21 |
// Create set of objects in loop |
| 22 |
for(int i = 0; i < 2; i++) { |
| 23 |
SampleClass *sample = [SampleClass new]; |
| 24 |
foo (sample->_value); |
| 25 |
} |
| 26 |
} |
| 27 |
@end |
| 28 |
// CHECK: [[IVAR:%.*]] = load i64, ptr @"OBJC_IVAR_$_SampleClass._value", align 8 |
| 29 |
// CHECK: [[ADDPTR:%.*]] = getelementptr inbounds i8, ptr [[CALL:%.*]], i64 [[IVAR]] |
| 30 |
// CHECK: [[FIVE:%.*]] = load i32, ptr [[ADDPTR]], align 4 |
| 31 |
// CHECK: call void @foo(i32 noundef [[FIVE]]) |
| 32 |
|
| 33 |
@implementation SampleClass |
| 34 |
+ (SampleClass*) new { return 0; } |
| 35 |
- (void) SampleClassApplication |
| 36 |
{ |
| 37 |
// Create set of objects in loop |
| 38 |
for(int i = 0; i < 2; i++) { |
| 39 |
SampleClass *sample = [SampleClass new]; |
| 40 |
foo (sample->_value); |
| 41 |
} |
| 42 |
} |
| 43 |
@end |
| 44 |
// CHECK: [[ZERO:%.*]] = load ptr, ptr @OBJC_SELECTOR_REFERENCES_, align 8, !invariant.load |
| 45 |
// CHECK: [[IVAR:%.*]] = load i64, ptr @"OBJC_IVAR_$_SampleClass._value", align 8, !invariant.load |
| 46 |
|
| 47 |
@interface Sample : SampleClass @end |
| 48 |
|
| 49 |
@implementation Sample |
| 50 |
- (void) SampleApplication |
| 51 |
{ |
| 52 |
// Create set of objects in loop |
| 53 |
for(int i = 0; i < 2; i++) { |
| 54 |
SampleClass *sample = [SampleClass new]; |
| 55 |
foo (sample->_value); |
| 56 |
} |
| 57 |
} |
| 58 |
@end |
| 59 |
// CHECK: [[ZERO:%.*]] = load ptr, ptr @OBJC_SELECTOR_REFERENCES_, align 8, !invariant.load |
| 60 |
// CHECK: [[IVAR:%.*]] = load i64, ptr @"OBJC_IVAR_$_SampleClass._value", align 8, !invariant.load |
| 61 |
|