Try this in a debugger: struct string { string() {} string(int i) : i(i) {} ~string() {} int i = 0; }; string get_string() { string unused; string result = 3; return result; } int main() { get_string(); } $ clang++ -g -fno-exceptions str.cpp $ gdb ./a.out b 10 r p result p *(string*)result Looks like there's a missing DW_OP_deref in here somehow.
Hmm.. I couldn't reproduce this my system compiler (apple-clang-802) and lldb and behold, the location also uses a DW_OP_deref AT_location( 0x00000000 0x0000000100000e88 - 0x0000000100000ebb: rbp-24, deref ) so perhaps this is a recent regression? With clang version 6.0.0 (trunk 310529) (llvm/trunk 310534) I get 0x00000055: TAG_variable [4] AT_location( 0x00000000 0x0000000100000e88 - 0x0000000100000ebb: rbp-24 ) and can reproduce the bug in lldb. I'll bisect now.
Looks like I broke this myself :-( [clang] Debug Info: Remove special-casing of indirect function argument handling. LLVM has changed the semantics of dbg.declare for describing function arguments. After this patch a dbg.declare always takes the *address* of a variable as the first argument, even if the argument is not an alloca. https://bugs.llvm.org/show_bug.cgi?id=32382 rdar://problem/31205000 git-original-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300523 Once I have a fix, I will add a variant of this test to the debuginfo-tests to avoid regressing again.
IMO the fix for this will live in LLVM, I've fixed this bug several times now while iterating on https://reviews.llvm.org/D37311. My current patch uses DW_OP_LLVM_memory, but I'm not happy with it.
Yes, that would be in line with the commit message and the intention of the LLVM patch (r642022) that the message is referring to.
After r313400 and r313399 this should work both in -O0 and in many cases when optimized. I added a debuginfo-tests test in r313401, so hopefully this doesn't regress.
*** Bug 35654 has been marked as a duplicate of this bug. ***