brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.9 KiB · 8354794 Raw
221 lines · plain
1// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -std=c++11 -emit-llvm -debug-info-kind=limited -o - | FileCheck %s2 3class S {4public:5	S& operator = (const S&);6	S (const S&);7	S ();8};9 10struct CGRect {11	CGRect & operator = (const CGRect &);12};13 14@interface I {15  S position;16  CGRect bounds;17}18 19@property(assign, nonatomic) S position;20@property CGRect bounds;21@property CGRect frame;22- (void)setFrame:(CGRect)frameRect;23- (CGRect)frame;24- (void) initWithOwner;25- (CGRect)extent;26- (void)dealloc;27@end28 29@implementation I30@synthesize position;31@synthesize bounds;32@synthesize frame;33 34// CHECK: define internal void @"\01-[I setPosition:]"35// CHECK: call noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @_ZN1SaSERKS_36// CHECK-NEXT: ret void37 38// Don't attach debug locations to the prologue instructions. These were39// leaking over from the previous function emission by accident.40// CHECK: define internal void @"\01-[I setBounds:]"({{.*}} {41// CHECK-NOT: !dbg42// CHECK: #dbg_declare43- (void)setFrame:(CGRect)frameRect {}44- (CGRect)frame {return bounds;}45 46- (void)initWithOwner {47  I* _labelLayer;48  CGRect labelLayerFrame = self.bounds;49  labelLayerFrame = self.bounds;50  _labelLayer.frame = labelLayerFrame;51}52 53- (void)dealloc54  {55      CGRect cgrect = self.extent;56  }57- (struct CGRect)extent {return bounds;}58 59@end60 61// CHECK-LABEL: define{{.*}} i32 @main62// CHECK: call void @_ZN1SC1ERKS_(ptr {{[^,]*}} [[AGGTMP:%[a-zA-Z0-9\.]+]], ptr noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) {{%[a-zA-Z0-9\.]+}})63// CHECK: call void @objc_msgSend(ptr noundef {{%[a-zA-Z0-9\.]+}}, ptr noundef {{%[a-zA-Z0-9\.]+}}, ptr dead_on_return noundef [[AGGTMP]])64// CHECK-NEXT: ret i32 065int main() {66  I *i;67  S s1;68  i.position = s1;69  return 0;70}71 72// CHECK-LABEL: define{{.*}} void @_Z1fP1A73// CHECK: call void @_ZN1XC1Ev(ptr {{[^,]*}} [[LVTEMP:%[a-zA-Z0-9\.]+]])74// CHECK: call void @_ZN1XC1ERKS_(ptr {{[^,]*}} [[AGGTMP:%[a-zA-Z0-9\.]+]], ptr noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[LVTEMP]])75// CHECK: call void @objc_msgSend({{.*}} ptr noundef [[AGGTMP]])76struct X {77  X();78  X(const X&);79  ~X();80};81 82@interface A {83  X xval;84}85- (X)x;86- (void)setX:(X)x;87@end88 89void f(A* a) {90  a.x = X();91}92 93//   Ensure that pseudo-objecet expressions that require the RHS to be94//   rewritten don't result in crashes or redundant emission of code.95struct B0 { long long x; };96struct B1 { long long x; }; B1 operator+(B1, B1);97struct B2 { B1 x; };98struct B3 { B3(); B1 x; operator B1(); };99@interface B100@property B0 b0;101@property B1 b1;102@property B2 b2;103@property B3 b3;104@end105 106int b_makeInt();107 108// Note that there's a promotion from int to long long, so109// the syntactic form of the RHS will be bogus.110void testB0(B *b) {111  b.b0 = { b_makeInt() };112}113void testB1(B *b) {114  b.b1 += { b_makeInt() };115}116// CHECK:    define{{.*}} void @_Z6testB0P1B(ptr117// CHECK:      [[BVAR:%.*]] = alloca ptr, align 8118// CHECK:      [[TEMP:%.*]] = alloca [[B0:%.*]], align 8119// CHECK:      [[X:%.*]] = getelementptr inbounds nuw [[B0]], ptr [[TEMP]], i32 0, i32 0120// CHECK-NEXT: [[T0:%.*]] = call noundef i32 @_Z9b_makeIntv()121// CHECK-NEXT: [[T1:%.*]] = sext i32 [[T0]] to i64122// CHECK-NEXT: store i64 [[T1]], ptr [[X]], align 8123// CHECK:      load ptr, ptr [[BVAR]]124// CHECK-NOT:  call125// CHECK:      call void @llvm.memcpy126// CHECK-NOT:  call127// CHECK:      call void @objc_msgSend128// CHECK-NOT:  call129// CHECK:      ret void130 131// CHECK:    define{{.*}} void @_Z6testB1P1B(ptr132// CHECK:      [[BVAR:%.*]] = alloca ptr, align 8133// CHECK:      load ptr, ptr [[BVAR]]134// CHECK-NOT:  call135// CHECK:      [[T0:%.*]] = call i64 @objc_msgSend136// CHECK-NOT:  call137// CHECK:      store i64 [[T0]],138// CHECK-NOT:  call139// CHECK:      [[T0:%.*]] = call noundef i32 @_Z9b_makeIntv()140// CHECK-NEXT: [[T1:%.*]] = sext i32 [[T0]] to i64141// CHECK-NEXT: store i64 [[T1]], ptr {{.*}}, align 8142// CHECK-NOT:  call143// CHECK:      [[T0:%.*]] = call i64 @_Zpl2B1S_144// CHECK-NOT:  call145// CHECK:      store i64 [[T0]],146// CHECK-NOT:  call147// CHECK:      call void @llvm.memcpy148// CHECK-NOT:  call149// CHECK:      call void @objc_msgSend150// CHECK-NOT:  call151// CHECK:      ret void152 153// Another example of a conversion that needs to be applied154// in the semantic form.155void testB2(B *b) {156  b.b2 = { B3() };157}158 159// CHECK:    define{{.*}} void @_Z6testB2P1B(ptr160// CHECK:      [[BVAR:%.*]] = alloca ptr, align 8161// CHECK:      #dbg_declare(162// CHECK:      call void @_ZN2B3C1Ev(163// CHECK-NEXT: [[T0:%.*]] = call i64 @_ZN2B3cv2B1Ev(164// CHECK-NOT:  call165// CHECK:      store i64 [[T0]],166// CHECK:      load ptr, ptr [[BVAR]]167// CHECK-NOT:  call168// CHECK:      call void @llvm.memcpy169// CHECK-NOT:  call170// CHECK:      call void @objc_msgSend171// CHECK-NOT:  call172// CHECK:      ret void173 174// A similar test to B, but using overloaded function references.175struct C1 {176  int x;177  friend C1 operator+(C1, void(&)());178};179@interface C180@property void (*c0)();181@property C1 c1;182@end183 184void c_helper();185void c_helper(int);186 187void testC0(C *c) {188  c.c0 = c_helper;189  c.c0 = &c_helper;190}191// CHECK:    define{{.*}} void @_Z6testC0P1C(ptr192// CHECK:      [[CVAR:%.*]] = alloca ptr, align 8193// CHECK:      load ptr, ptr [[CVAR]]194// CHECK-NOT:  call195// CHECK:      call void @objc_msgSend({{.*}} @_Z8c_helperv196// CHECK-NOT:  call197// CHECK:      call void @objc_msgSend({{.*}} @_Z8c_helperv198// CHECK-NOT:  call199// CHECK:      ret void200 201void testC1(C *c) {202  c.c1 += c_helper;203}204// CHECK:    define{{.*}} void @_Z6testC1P1C(ptr205// CHECK:      [[CVAR:%.*]] = alloca ptr, align 8206// CHECK:      load ptr, ptr [[CVAR]]207// CHECK-NOT:  call208// CHECK:      [[T0:%.*]] = call i32 @objc_msgSend209// CHECK-NOT:  call210// CHECK:      store i32 [[T0]],211// CHECK-NOT:  call212// CHECK:      [[T0:%.*]] = call i32 @_Zpl2C1RFvvE({{.*}} @_Z8c_helperv213// CHECK-NOT:  call214// CHECK:      store i32 [[T0]],215// CHECK-NOT:  call216// CHECK:      call void @llvm.memcpy217// CHECK-NOT:  call218// CHECK:      call void @objc_msgSend219// CHECK-NOT:  call220// CHECK:      ret void221