Amy Huang | 7fac5c8 | 2019-06-20 17:15:21 +0000 | [diff] [blame^] | 1 | // 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 |
| 3 | struct Foo { |
| 4 | Foo() = default; |
| 5 | Foo(Foo &&other) { x = other.x; } |
| 6 | int x; |
| 7 | }; |
| 8 | void some_function(int); |
| 9 | Foo getFoo() { |
| 10 | Foo foo; |
| 11 | foo.x = 41; |
| 12 | some_function(foo.x); |
| 13 | return foo; |
| 14 | } |
| 15 | |
| 16 | int 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() |