xref: /llvm-project/clang/test/CodeGenObjCXX/nrvo.mm (revision 0f1c1be1968076d6f96f8a7bcc4a15cf195ecd97)
1// RUN: %clang_cc1 -emit-llvm -o - -fblocks %s -O1 -fno-inline-functions -triple x86_64-apple-darwin10.0.0 -fobjc-runtime=macosx-fragile-10.5 | FileCheck %s
2
3// PR10835
4struct X {
5  X();
6  X(const X&);
7  ~X();
8};
9
10@interface NRVO
11@end
12
13@implementation NRVO
14// CHECK: define internal void @"\01-[NRVO getNRVO]"
15- (X)getNRVO {
16  X x;
17  // CHECK: call void @_ZN1XC1Ev
18  // CHECK-NEXT: ret void
19  return x;
20}
21@end
22
23X blocksNRVO() {
24  return ^{
25    // With the optimizer enabled, the DeadArgElim pass is able to
26    // mark the block litteral address argument as unused and later the
27    // related block_litteral global variable is removed.
28    // This allows to promote this call to a fastcc call.
29    // CHECK-LABEL: define internal fastcc void @___Z10blocksNRVOv_block_invoke
30    X x;
31    // CHECK: call void @_ZN1XC1Ev
32    // CHECK-NEXT: ret void
33    return x;
34  }() ;
35}
36
37