1 // RUN: %clangxx -Xclang -no-opaque-pointers -target x86_64-unknown-unknown -g \ 2 // RUN: %s -emit-llvm -S -o - | FileCheck %s 3 4 // RUN: %clangxx -Xclang -no-opaque-pointers -target x86_64-unknown-unknown -g \ 5 // RUN: -fno-elide-constructors %s -emit-llvm -S -o - | \ 6 // RUN: FileCheck %s -check-prefix=NOELIDE 7 8 struct Foo { 9 Foo() = default; 10 Foo(Foo &&other) { x = other.x; } 11 int x; 12 }; 13 void some_function(int); 14 Foo getFoo() { 15 Foo foo; 16 foo.x = 41; 17 some_function(foo.x); 18 return foo; 19 } 20 21 int 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 29 // CHECK: %[[RESULT:.*]] = alloca i8*, align 8 30 // CHECK: call void @llvm.dbg.declare(metadata i8** %[[RESULT]], 31 // CHECK-SAME: metadata !DIExpression(DW_OP_deref) 32 33 // NOELIDE: %[[FOO:.*]] = alloca %struct.Foo, align 4 34 // NOELIDE: call void @llvm.dbg.declare(metadata %struct.Foo* %[[FOO]], 35 // NOELIDE-SAME: metadata !DIExpression() 36