52 lines · cpp
1// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir2// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR3// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-elide-constructors -fclangir -emit-cir %s -o %t-noelide.cir4// RUN: FileCheck --input-file=%t-noelide.cir %s --check-prefix=CIR-NOELIDE5// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll6// RUN: FileCheck --input-file=%t-cir.ll %s --check-prefix=LLVM7// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll8// RUN: FileCheck --input-file=%t.ll %s --check-prefix=OGCG9 10// There are no LLVM and OGCG tests with -fno-elide-constructors because the11// lowering isn't of interest for this test. We just need to see that the12// copy constructor is elided without -fno-elide-constructors but not with it.13 14struct S {15 S();16 int a;17 int b;18};19 20struct S f1() {21 S s;22 return s;23}24 25// CIR: cir.func{{.*}} @_Z2f1v() -> !rec_S26// CIR-NEXT: %[[RETVAL:.*]] = cir.alloca !rec_S, !cir.ptr<!rec_S>, ["__retval", init]27// CIR-NEXT: cir.call @_ZN1SC1Ev(%[[RETVAL]]) : (!cir.ptr<!rec_S>) -> ()28// CIR-NEXT: %[[RET:.*]] = cir.load %[[RETVAL]] : !cir.ptr<!rec_S>, !rec_S29// CIR-NEXT: cir.return %[[RET]]30 31// CIR-NOELIDE: cir.func{{.*}} @_Z2f1v() -> !rec_S32// CIR-NOELIDE-NEXT: %[[RETVAL:.*]] = cir.alloca !rec_S, !cir.ptr<!rec_S>, ["__retval"]33// CIR-NOELIDE-NEXT: %[[S:.*]] = cir.alloca !rec_S, !cir.ptr<!rec_S>, ["s", init]34// CIR-NOELIDE-NEXT: cir.call @_ZN1SC1Ev(%[[S]]) : (!cir.ptr<!rec_S>) -> ()35// CIR-NOELIDE-NEXT: cir.call @_ZN1SC1EOS_(%[[RETVAL]], %[[S]]){{.*}} : (!cir.ptr<!rec_S>, !cir.ptr<!rec_S>) -> ()36// CIR-NOELIDE-NEXT: %[[RET:.*]] = cir.load %[[RETVAL]] : !cir.ptr<!rec_S>, !rec_S37// CIR-NOELIDE-NEXT: cir.return %[[RET]]38 39// FIXME: Update this when calling convetnion lowering is implemented.40// LLVM: define{{.*}} %struct.S @_Z2f1v()41// LLVM-NEXT: %[[RETVAL:.*]] = alloca %struct.S42// LLVM-NEXT: call void @_ZN1SC1Ev(ptr %[[RETVAL]])43// LLVM-NEXT: %[[RET:.*]] = load %struct.S, ptr %[[RETVAL]]44// LLVM-NEXT: ret %struct.S %[[RET]]45 46// OGCG: define{{.*}} i64 @_Z2f1v()47// OGCG-NEXT: entry:48// OGCG-NEXT: %[[RETVAL:.*]] = alloca %struct.S49// OGCG-NEXT: call void @_ZN1SC1Ev(ptr {{.*}} %[[RETVAL]])50// OGCG-NEXT: %[[RET:.*]] = load i64, ptr %[[RETVAL]]51// OGCG-NEXT: ret i64 %[[RET]]52