[all-commits] [llvm/llvm-project] 84f6e1: [DebugInfo] Clone dbg.values in SimplifyCFG like n...

Jeremy Morse via All-commits all-commits at lists.llvm.org
Fri Nov 24 05:31:23 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 84f6e1d71c19bccd13a23a008ed815391e4f6b8e
      https://github.com/llvm/llvm-project/commit/84f6e1d71c19bccd13a23a008ed815391e4f6b8e
  Author: Jeremy Morse <jeremy.morse at sony.com>
  Date:   2023-11-24 (Fri, 24 Nov 2023)

  Changed paths:
    M llvm/lib/Transforms/Utils/SimplifyCFG.cpp
    M llvm/test/Transforms/SimplifyCFG/branch-fold-dbg.ll

  Log Message:
  -----------
  [DebugInfo] Clone dbg.values in SimplifyCFG like normal instructions (#72526)

The code in the CloneInstructionsIntoPredec... function modified by this
patch has a long history that dates back to 2011, see d715ec82b4ad12c59.
There, when folding branches, all dbg.value intrinsics seen when folding
would be saved and then re-inserted at the end of whatever was folded. Over
the last 12 years this behaviour has been preserved.

However, IMO it's bad behaviour. If we have:

  inst1
  dbg.value1
  inst2
  dbg.value2

And we fold that sequence into a different block, then we would want the
instructions and variable assignments to appear in the same order. However
because of this old behaviour, the dbg.values are sunk, and we get:

  inst1
  inst2
  dbg.value1
  dbg.value2

This clustering of dbg.values can make assignments to the same variable
invisible, as well as reducing the coverage of other assignments.

This patch relaxes the CloneInstructions... function and allows it to clone
and update dbg.values in-place, causing them to appear in the original
order in the destination block. I've added some extra dbg.values to the
updated test: without the changes to the pass, the dbg.values sink into a
blob ahead of the select. The RemoveDIs code can't cope with this right now
so I've removed the "--try..." flag, restored in a commit to land in a
couple of hours.

(Metadata changes to make the LLVM-IR parser not drop the debug-info for it
being out of date. The RemoveDIs related RUN line has been removed because
it was spuriously passing due to the debug-info being dropped).




More information about the All-commits mailing list