36 lines · cpp
1// RUN: %clangxx -target x86_64-unknown-unknown -g \2// RUN: %s -emit-llvm -S -o - | FileCheck %s3 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=NOELIDE7 8struct 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 are27// stored in the return register.28 29// CHECK: %[[RESULT:.*]] = alloca ptr, align 830// CHECK: #dbg_declare(ptr %[[RESULT]],31// CHECK-SAME: !DIExpression(DW_OP_deref)32 33// NOELIDE: %[[FOO:.*]] = alloca %struct.Foo, align 434// NOELIDE: #dbg_declare(ptr %[[FOO]],35// NOELIDE-SAME: !DIExpression()36