Page MenuHomePhabricator

[Debuginfo] (6/N) Support for DW_OP_implicit_pointer for named and unnamed variables (second strategy).
Needs ReviewPublic

Authored by alok on Jul 18 2020, 5:09 PM.

Details

Reviewers
dblaikie
Summary
This patch stems from D84112.
This patch includes improvement in debuginfo salvaging.

Diff Detail

Event Timeline

alok created this revision.Jul 18 2020, 5:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 18 2020, 5:09 PM
jmorse added a subscriber: jmorse.Jul 30 2020, 5:58 AM

Could you elaborate on why module-level information needs to be preserved? As mentioned on llvm-dev, I think you might have missed a place where promotion from stack to SSA/values happens -- IMHO we shouldn't add module-level debuginfo-tracking unless it's absolutely necessary.

llvm/include/llvm/IR/Module.h
205

You'll need to use a value handle (WeakVH perhaps) to store Value references, to avoid storing pointers that become dangling pointers later. The comment should indicate what's being mapped -- I believe it's old alloca to the DILocalVariable, because insertVarAddressMap inserts the second operand of a dbg.declare?

In addition, it looks like salvageDebugInfoForDbgValues never dereferences the mapped value, so could this instead be a set instead of a map?

llvm/lib/IR/Instruction.cpp
84–85

Does this make the debug-info metadata code in the Instruction destructor redundant?

795–798

The rest of Instruction.cpp is very detail-agnostic, and it seems out of place to check the DWARF version here (and presumably meaningless for CodeView). Could this be turned into a more generic compile option, or target option, so that it's less DWARF specific?

(It might be that LLVM doesn't support such a form of option).

807–808

Quite a lot of this function is now dedicated to "if we're an alloca being deleted, that had associated dbg.declares". IMO, it's clearer to put that code into a separate function.

llvm/test/DebugInfo/X86/implicit_pointer_temp_dyn_alloc.cc
1–2

We can't call clang from within llvm as it's not guaranteed to be built. Getting the unoptimised IR with -O0 -gdwarf-5 -emit-llvm -S -Xclang -disable-O0-optnone, and writing a normal lit test for that, would be best.

You might also want to put an end-to-end Dexter test into the debuginfo-tests.

llvm/unittests/IR/DebugInfoTest.cpp
185

This should be a positive test that the dbg.value points at a correct thing, not that it doesn't point at an undef. There are a variety of other Values it could point at by mistake.