blob: a03571aeac1ccf2e1ae715bfbaf03743e62a1393 [file] [log] [blame]
Amy Huang7fac5c82019-06-20 17:15:21 +00001// RUN: %clangxx -target x86_64-unknown-unknown -g %s -emit-llvm -S -o - | FileCheck %s
2// RUN: %clangxx -target x86_64-unknown-unknown -g -fno-elide-constructors %s -emit-llvm -S -o - | FileCheck %s -check-prefix=NOELIDE
3struct Foo {
4 Foo() = default;
5 Foo(Foo &&other) { x = other.x; }
6 int x;
7};
8void some_function(int);
9Foo getFoo() {
10 Foo foo;
11 foo.x = 41;
12 some_function(foo.x);
13 return foo;
14}
15
16int main() {
17 Foo bar = getFoo();
18 return bar.x;
19}
20
21// Check that NRVO variables are stored as a pointer with deref if they are
22// stored in the return register.
23
24// CHECK: %result.ptr = alloca i8*, align 8
25// CHECK: call void @llvm.dbg.declare(metadata i8** %result.ptr,
26// CHECK-SAME: metadata !DIExpression(DW_OP_deref)
27// NOELIDE: call void @llvm.dbg.declare(metadata %struct.Foo* %foo,
28// NOELIDE-SAME: metadata !DIExpression()