[PATCH] D88232: [DebugInfo] Handle multiple variable location operands in IR

Stephen Tozer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 24 08:04:26 PDT 2020


StephenTozer created this revision.
StephenTozer added reviewers: aprantl, djtodoro, vsk, dblaikie, probinson, dstenb.
StephenTozer added a project: debug-info.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
StephenTozer requested review of this revision.

Following from the previous patch in this series which enables DIArgLists with a single location operand in debug intrinsics, this patch updates the various IR passes to correctly handle multiple location operands.

Compared to the previous 2 patches, this one has the most actual logic, rather than simply being an interface or data change. This patch does not allow salvageDebugInfo to produce DIArgLists by salvaging instructions with a non-constant second operand; it also does not update almost any of CodeGen. Other than that, it should cover every IR pass.

Most of the changes are relatively straightforward, as we simply extend code that operated on a single debug value to operate on the list of debug values in the style of any_of, all_of, for_each, etc. We also have replaced `setOperand(0, ...)` with `replaceVariableLocationOp`, which requires us to pass the variable that is being replaced. In places where this value isn't readily available, we have to track the old value through to the point where it gets replaced.

One of the more complicated cases is `insertDebugValuesForPHIs`; the comments have been updated to explain the new implementation, but I imagine it'll take some effort to confirm that the implementation does what it says on the tin. Also, a question that I don't have a definitive answer on yet: how do we handle moving dbg.values that depend on multiple instructions? It's quite possible there's no way to preserve many of them, because when we move them to follow a sunk or hoisted instruction we risk losing the other instructions. `placeDbgValues` simply gives up for dbg.values with multiple location operands, as it isn't particularly reliable even in the single op case. As currently stands, I believe that the new `insertDebugValuesForPHIs` will always produce valid dbg.values, but am interested to find out if anyone sees an error with the logic or has an example where it fails.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88232

Files:
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/include/llvm/Transforms/Utils/Local.h
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/IR/DebugInfoMetadata.cpp
  llvm/lib/Target/AArch64/AArch64StackTagging.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
  llvm/lib/Transforms/Scalar/ADCE.cpp
  llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp
  llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
  llvm/lib/Transforms/Utils/CodeExtractor.cpp
  llvm/lib/Transforms/Utils/Debugify.cpp
  llvm/lib/Transforms/Utils/LCSSA.cpp
  llvm/lib/Transforms/Utils/Local.cpp
  llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
  llvm/unittests/IR/DebugInfoTest.cpp
  llvm/unittests/Transforms/Utils/LocalTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88232.294062.patch
Type: text/x-patch
Size: 29726 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200924/7ced9564/attachment.bin>


More information about the llvm-commits mailing list