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