Missing entry value debug location for inlined function parameter
LLVM trunk f7cd55f56e9413f37474c8c12fc0a6231bf5fca5.
Related to umbrella ticket #43461.
Compiling the given program:
volatile int global;
static inline void inlined(int ip) {
global = ip;
__asm volatile ("" : : : "edi");
global = 456; // line 6
}
void callee(int p) __attribute__((noinline)) {
inlined(p);
}
int main() {
callee(123);
return 0;
}
using:
clang -g -S -O3 -o - entry_value_inline.c
gives:
#DEBUG_VALUE: callee:p <- $edi
#DEBUG_VALUE: inlined:ip <- $edi
.loc 0 4 10 prologue_end # entry_value_inline.c:4:10
movl %edi, global(%rip)
.loc 0 5 3 # entry_value_inline.c:5:3
#APP
#NO_APP
.Ltmp0:
#DEBUG_VALUE: callee:p <- [DW_OP_LLVM_entry_value 1] $edi
.loc 0 6 10 # entry_value_inline.c:6:10
movl $456, global(%rip) # imm = 0x1C8
Here, we should be able to insert a entry-value debug location for ip:
#DEBUG_VALUE: inlined:ip <- [DW_OP_LLVM_entry_value 1] $edi
at .Ltmp0.
It was a while since I looked at this, but I think in general entry value debug locations are not emitted for variables originating from inlined functions.
@llvm/issue-subscribers-debuginfo
(CC @djtodoro), I think that makes sense, as far as I'm aware there's no principled reason why we couldn't use entry values to describe any variable location in DWARF. There are filters in both LiveDebugValues implementations that skip any inlined variables, we'd just need to remove those.
Hmm, the problem is that we do not generate DW_TAG_call_site (along with the DW_TAG_call_site_parameters, which we use when evaluating the entry_values) for inlined calls, since we do it for normal and tail calls only.
I don't know if we can use DW_TAG_inlined_subroutine for this.
I think an entry_value in an variable in an inlined subroutine would refer to the call site of the enclosing subprogram, not the inlined subroutine (there'd be no need to use an entry_value for the inlined call site - the code is already specialized for that call site)... so I think just removing the restriction would be fine, probably?
I think an entry_value in an variable in an inlined subroutine would refer to the call site of the enclosing subprogram, not the inlined subroutine (there'd be no need to use an entry_value for the inlined call site - the code is already specialized for that call site)... so I think just removing the restriction would be fine, probably?
Hmm, yes, I think you are right. Actually, there is nothing in the DWARF that says the opposite, so I guess it is the way to go.