[PATCH] D68209: [LiveDebugValues] Introduce entry values of unmodified params
Djordje Todorovic via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 21 08:10:24 PST 2019
djtodoro added a comment.
When trying to test the `lldb/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/TestBasicEntryValuesX86_64.py` I realized few things.
First of all, we are relying on the premise that whenever a source variable is set to a new value, we have a new `llvm.dbg.value()`[0].
By looking at the example [1], especially the code for function `func1()`, it looks like it is not the case here:
__attribute__((noinline))
void func1(int &sink, int x) {
use(x);
// Destroy 'x' in the current frame.
DESTROY_RSI;
//% self.filecheck("image lookup -va $pc", "main.cpp", "-check-prefix=FUNC1-DESC")
// FUNC1-DESC: name = "x", type = "int", location = DW_OP_entry_value(DW_OP_reg4 RSI)
++sink;
}
the IR looks like (compiled with `-g -O2`):
; Function Attrs: noinline nounwind uwtable
define dso_local void @_Z5func1Rii(i32* nocapture dereferenceable(4) %sink, i32 %x) local_unnamed_addr #0 !dbg !14 {
entry:
call void @llvm.dbg.value(metadata i32* %sink, metadata !19, metadata !DIExpression()), !dbg !21
call void @llvm.dbg.value(metadata i32 %x, metadata !20, metadata !DIExpression()), !dbg !21
tail call void @_Z3useIiEvT_(i32 %x), !dbg !22
tail call void asm sideeffect "xorq %rsi, %rsi", "~{rsi},~{dirflag},~{fpsr},~{flags}"() #4, !dbg !23, !srcloc !24
%0 = load i32, i32* %sink, align 4, !dbg !25, !tbaa !26
%inc = add nsw i32 %0, 1, !dbg !25
store i32 %inc, i32* %sink, align 4, !dbg !25, !tbaa !26
ret void, !dbg !30
}
therefore, the resulting MIR does not have a `DBG_VALUE` representing the `++sink;`, and with this approach, we will assume the value of the variable has not change by implying that we are able to generate the `DW_OP_entry_value` expression for it.
At the moment, we should avoid creating the entry value for the `sink` variable. Eventually, when we add support for the entry values of modified parameters, this should be (`(DW_OP_GNU_entry_value: (DW_OP_reg5 (rdi)); DW_OP_plus_uconst: 1; DW_OP_stack_value)`), and that is what `GCC` generates for it.
In addition, the parameter `x` gets copied into a register that is not a callee saved, and we are not able to assume that the value has not change in that case, so we do not generate the entry value in that case..
[0] https://llvm.org/docs/SourceLevelDebugging.html#llvm-dbg-value
[1] https://github.com/llvm/llvm-project/blob/master/lldb/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/main.cpp#L27
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D68209/new/
https://reviews.llvm.org/D68209
More information about the llvm-commits
mailing list