Saleem Abdulrasool | 961f570 | 2013-02-17 04:03:34 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin -x objective-c %s -o - | FileCheck %s |
| 2 | |
| 3 | @interface NSObject |
| 4 | + (id) new; |
| 5 | - (id) init; |
| 6 | @end |
| 7 | |
| 8 | @interface Base : NSObject @end |
| 9 | |
| 10 | // @implementation Base |
| 11 | // { |
| 12 | // int dummy; |
| 13 | // } |
| 14 | // @end |
| 15 | |
| 16 | @interface Derived : Base |
| 17 | { |
| 18 | @public int member; |
| 19 | } |
| 20 | @end |
| 21 | |
| 22 | @implementation Derived |
| 23 | - (id) init |
| 24 | { |
| 25 | self = [super init]; |
| 26 | member = 42; |
| 27 | return self; |
| 28 | } |
| 29 | @end |
| 30 | |
| 31 | // CHECK: [[IVAR:%.*]] = load i64* @"OBJC_IVAR_$_Derived.member", !invariant.load |
| 32 | |
| 33 | void * variant_load_1(int i) { |
| 34 | void *ptr; |
| 35 | while (i--) { |
| 36 | Derived *d = [Derived new]; |
| 37 | ptr = &d->member; |
| 38 | } |
| 39 | return ptr; |
| 40 | } |
| 41 | |
| 42 | // CHECK: [[IVAR:%.*]] = load i64* @"OBJC_IVAR_$_Derived.member"{{$}} |
| 43 | |
| 44 | @interface Container : Derived @end |
| 45 | @implementation Container |
| 46 | - (void *) invariant_load_1 |
| 47 | { |
| 48 | return &self->member; |
| 49 | } |
| 50 | @end |
| 51 | |
| 52 | // CHECK: [[IVAR:%.*]] = load i64* @"OBJC_IVAR_$_Derived.member", !invariant.load |
| 53 | |