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