llvm-project/clang/test/CodeGenObjC/optimize-ivar-offset-load.m
Mehdi Amini e0ac46e69d Revert "Remove rdar links; NFC"
This reverts commit d618f1c3b12effd0c2bdb7d02108d3551f389d3d.
This commit wasn't reviewed ahead of time and significant concerns were
raised immediately after it landed. According to our developer policy
this warrants immediate revert of the commit.

https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy

Differential Revision: https://reviews.llvm.org/D155509
2023-07-17 18:08:04 -07:00

63 lines
1.6 KiB
Objective-C

// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -O0 -emit-llvm %s -o - | FileCheck %s
// rdar://16095748
@interface MyNSObject
@end
@interface SampleClass : MyNSObject {
@public
int _value;
}
+ (SampleClass*) new;
@end
@interface AppDelegate : MyNSObject
@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, ptr @"OBJC_IVAR_$_SampleClass._value", align 8
// CHECK: [[ADDPTR:%.*]] = getelementptr inbounds i8, ptr [[CALL:%.*]], i64 [[IVAR]]
// CHECK: [[FIVE:%.*]] = load i32, ptr [[ADDPTR]], align 4
// CHECK: call void @foo(i32 noundef [[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 ptr, ptr @OBJC_SELECTOR_REFERENCES_, align 8, !invariant.load
// CHECK: [[IVAR:%.*]] = load i64, ptr @"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 ptr, ptr @OBJC_SELECTOR_REFERENCES_, align 8, !invariant.load
// CHECK: [[IVAR:%.*]] = load i64, ptr @"OBJC_IVAR_$_SampleClass._value", align 8, !invariant.load