brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.6 KiB · f7eb0cc Raw
219 lines · cpp
1// RUN: %clang_cc1 -triple aarch64-windows -ffreestanding -emit-llvm -O0 \2// RUN: -x c++ -o - %s | FileCheck %s3 4// Pass and return for type size <= 8 bytes.5// CHECK: define {{.*}} i64 @{{.*}}f1{{.*}}()6// CHECK: call i64 {{.*}}func1{{.*}}(i64 %0)7struct S1 {8  int a[2];9};10 11S1 func1(S1 x);12S1 f1() {13  S1 x;14  return func1(x);15}16 17// Pass and return type size <= 16 bytes.18// CHECK: define {{.*}} [2 x i64] @{{.*}}f2{{.*}}()19// CHECK: call [2 x i64] {{.*}}func2{{.*}}([2 x i64] %0)20struct S2 {21  int a[4];22};23 24S2 func2(S2 x);25S2 f2() {26  S2 x;27  return func2(x);28}29 30// Pass and return for type size > 16 bytes.31// CHECK: define {{.*}} void @{{.*}}f3{{.*}}(ptr dead_on_unwind noalias writable sret(%struct.S3) align 4 %agg.result)32// CHECK: call void {{.*}}func3{{.*}}(ptr dead_on_unwind writable sret(%struct.S3) align 4 %agg.result, ptr dead_on_return noundef %agg.tmp)33struct S3 {34  int a[5];35};36 37S3 func3(S3 x);38S3 f3() {39  S3 x;40  return func3(x);41}42 43// Pass and return aggregate (of size < 16 bytes) with non-trivial destructor.44// Passed directly but returned indirectly.45// CHECK: define {{.*}} void {{.*}}f4{{.*}}(ptr dead_on_unwind inreg noalias writable sret(%struct.S4) align 4 %agg.result)46// CHECK: call void {{.*}}func4{{.*}}(ptr dead_on_unwind inreg writable sret(%struct.S4) align 4 %agg.result, [2 x i64] %0)47struct S4 {48  int a[3];49  ~S4();50};51 52S4 func4(S4 x);53S4 f4() {54  S4 x;55  return func4(x);56}57 58// Pass and return from instance method called from instance method.59// CHECK: define {{.*}} void @{{.*}}bar@Q1{{.*}}(ptr {{[^,]*}} %this, ptr dead_on_unwind inreg noalias writable sret(%class.P1) align 1 %agg.result)60// CHECK: call void {{.*}}foo@P1{{.*}}(ptr noundef{{[^,]*}} %ref.tmp, ptr dead_on_unwind inreg writable sret(%class.P1) align 1 %agg.result, i64 %coerce.val.ii)61 62class P1 {63public:64  P1 foo(P1 x);65};66 67class Q1 {68public:69  P1 bar();70};71 72P1 Q1::bar() {73  P1 p1;74  return P1().foo(p1);75}76 77// Pass and return from instance method called from free function.78// CHECK: define {{.*}} void {{.*}}bar{{.*}}()79// CHECK: call void {{.*}}foo@P2{{.*}}(ptr noundef{{[^,]*}} %ref.tmp, ptr dead_on_unwind inreg writable sret(%class.P2) align 1 %retval, i64 %coerce.val.ii)80class P2 {81public:82  P2 foo(P2 x);83};84 85P2 bar() {86  P2 p2;87  return P2().foo(p2);88}89 90// Pass and return an object with a user-provided constructor (passed directly,91// returned indirectly)92// CHECK: define {{.*}} void @{{.*}}f5{{.*}}(ptr dead_on_unwind inreg noalias writable sret(%struct.S5) align 4 %agg.result)93// CHECK: call void {{.*}}func5{{.*}}(ptr dead_on_unwind inreg writable sret(%struct.S5) align 4 %agg.result, i64 {{.*}})94struct S5 {95  S5();96  int x;97};98 99S5 func5(S5 x);100S5 f5() {101  S5 x;102  return func5(x);103}104 105// Pass and return an object with a non-trivial explicitly defaulted constructor106// (passed directly, returned directly)107// CHECK: define {{.*}} i8 @"?f6@@YA?AUS6@@XZ"()108// CHECK: call i8 {{.*}}func6{{.*}}(i64 {{.*}})109struct S6a {110  S6a();111};112 113struct S6 {114  S6() = default;115  S6a x;116};117 118S6 func6(S6 x);119S6 f6() {120  S6 x;121  return func6(x);122}123 124// Pass and return an object with a non-trivial implicitly defaulted constructor125// (passed directly, returned directly)126// CHECK: define {{.*}} i8 @"?f7@@YA?AUS7@@XZ"()127// CHECK: call i8 {{.*}}func7{{.*}}(i64 {{.*}})128struct S7 {129  S6a x;130};131 132S7 func7(S7 x);133S7 f7() {134  S7 x;135  return func7(x);136}137 138struct S8a {139  ~S8a();140};141 142// Pass and return an object with a non-trivial default destructor (passed143// directly, returne indirectly)144struct S8 {145  S8a x;146  int y;147};148 149// CHECK: define {{.*}} void {{.*}}?f8{{.*}}(ptr dead_on_unwind inreg noalias writable sret(%struct.S8) align 4 {{.*}})150// CHECK: call void {{.*}}func8{{.*}}(ptr dead_on_unwind inreg writable sret(%struct.S8) align 4 {{.*}}, i64 {{.*}})151S8 func8(S8 x);152S8 f8() {153  S8 x;154  return func8(x);155}156 157 158// Pass and return an object with a non-trivial copy-assignment operator and159// a trivial copy constructor (passed directly, returned indirectly)160// CHECK: define {{.*}} void @"?f9@@YA?AUS9@@XZ"(ptr dead_on_unwind inreg noalias writable sret(%struct.S9) align 4 {{.*}})161// CHECK: call void {{.*}}func9{{.*}}(ptr dead_on_unwind inreg writable sret(%struct.S9) align 4 {{.*}}, i64 {{.*}})162struct S9 {163  S9& operator=(const S9&);164  int x;165};166 167S9 func9(S9 x);168S9 f9() {169  S9 x;170  S9 y = x;171  x = y;172  return func9(x);173}174 175// Pass and return an object with a base class (passed directly, returned176// indirectly).177// CHECK: define dso_local void {{.*}}f10{{.*}}(ptr dead_on_unwind inreg noalias writable sret(%struct.S10) align 4 {{.*}})178// CHECK: call void {{.*}}func10{{.*}}(ptr dead_on_unwind inreg writable sret(%struct.S10) align 4 {{.*}}, [2 x i64] {{.*}})179struct S10 : public S1 {180  int x;181};182 183S10 func10(S10 x);184S10 f10() {185  S10 x;186  return func10(x);187}188 189 190// Pass and return a non aggregate object exceeding > 128 bits (passed191// indirectly, returned indirectly)192// CHECK: define dso_local void {{.*}}f11{{.*}}(ptr dead_on_unwind inreg noalias writable sret(%struct.S11) align 8 {{.*}})193// CHECK: call void {{.*}}func11{{.*}}(ptr dead_on_unwind inreg writable sret(%struct.S11) align 8 {{.*}}, ptr {{.*}})194struct S11 {195  virtual void f();196  int a[5];197};198 199S11 func11(S11 x);200S11 f11() {201  S11 x;202  return func11(x);203}204 205// GH86384206// Pass and return object with template constructor (pass directly,207// return indirectly).208// CHECK: define dso_local void @"?f12@@YA?AUS12@@XZ"(ptr dead_on_unwind inreg noalias writable sret(%struct.S12) align 4 {{.*}})209// CHECK: call void @"?func12@@YA?AUS12@@U1@@Z"(ptr dead_on_unwind inreg writable sret(%struct.S12) align 4 {{.*}}, i64 {{.*}})210struct S12 {211  template<typename T> S12(T*) {}212  int x;213};214S12 func12(S12 x);215S12 f12() {216  S12 x((int*)0);217  return func12(x);218}219