llvm-project/clang/test/CodeGenObjCXX/property-object-reference.mm
Ahmed Bougacha ecb502342c [ObjC] Emit selector load right before msgSend call.
We currently emit the selector load early, but only because we need
it to compute the signature (so that we know which msgSend variant to
call).  We can prepare the signature with a plain undef, and replace
it with the materialized selector value if (and only if) needed, later.

Concretely, this usually doesn't have an effect, but tests need updating
because we reordered the receiver bitcast and the selector load, which
is always fine.

There is one notable change: with this, when a msgSend needs a
receiver null check, the selector is now loaded in the non-null
block, instead of before the null check.  That should be a mild
improvement.
2022-01-26 20:52:54 -08:00

36 lines
945 B
Plaintext

// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - | FileCheck %s
// rdar://10188258
struct Foo {int i;};
static Foo gFoo;
@interface ObjCTest { }
@property (nonatomic, readonly) Foo& FooRefProperty;
@property (nonatomic) Foo FooProperty;
- (Foo &) FooProperty;
- (void)setFooProperty : (Foo &) arg;
@end
@implementation ObjCTest
@dynamic FooRefProperty;
-(void) test {
Foo& f = self.FooRefProperty;
Foo& f1 = self.FooProperty;
}
- (Foo &) FooProperty { return gFoo; }
- (void)setFooProperty : (Foo &) arg { };
@end
// CHECK: [[T0:%.*]] = load {{%.*}} [[S0:%.*]]
// CHECK: [[T2:%.*]] = bitcast {{%.*}} [[T0]] to i8*
// CHECK: load i8*, i8** @OBJC_SELECTOR_REFERENCES_
// CHECK: @objc_msgSend
// CHECK: [[R0:%.*]] = load {{%.*}} [[U0:%.*]]
// CHECK: [[R2:%.*]] = bitcast {{%.*}} [[R0]] to i8*
// CHECK: load i8*, i8** @OBJC_SELECTOR_REFERENCES_
// CHECK: @objc_msgSend