[Assignment Tracking] Coalesce dbg loc definitions with contiguous fragments
authorOCHyams <orlando.hyams@sony.com>
Wed, 29 Mar 2023 14:27:29 +0000 (15:27 +0100)
committerOCHyams <orlando.hyams@sony.com>
Wed, 29 Mar 2023 14:59:46 +0000 (15:59 +0100)
commitd4879d769095d76ddf9484c50661feac96ce525a
tree2985d0abfedd043447248a4ad549f8b4add1b1d8
parent8e56a196fb5c26e556ac267986868a3f63b7c486
[Assignment Tracking] Coalesce dbg loc definitions with contiguous fragments

MemLocFragmentFill uses an IntervalMap to track which bits of each variable are
stack-homed. Intervals with the same value (same stack location base address)
are automatically coalesced by the map. This patch changes the analysis to take
advantage of that and insert a new dbg loc after each def if any coalescing
took place. This results in some additional redundant defs (we insert a def,
then another that by definition shadows the previous one if any coalescing took
place) but they're all cleaned up thanks to the previous patch in this stack.

This reduces the total number of fragments created by
AssignmentTrackingAnalysis which reduces compile time because LiveDebugValues
computes SSA for every fragment it encounters. There's a geomean reduction in
instructions retired in a CTMark LTO-O3-g build of 0.3% with these two patches.

One small caveat is that this technique can produce partially overlapping
fragments (e.g. slice [0, 32) and slice [16, 64)), which we know
LiveDebugVariables doesn't really handle correctly. Used in combination with
instruction-referencing this isn't a problem, since LiveDebugVariables is
effectively side-stepped in instruction-referencing mode. Given this, the
coalescing is only enabled when instruction-referencing is enabled (but the
behaviour can be overriden using -debug-ata-coalesce-frags=<bool>).

Reviewed By: jmorse

Differential Revision: https://reviews.llvm.org/D146980
llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
llvm/test/DebugInfo/assignment-tracking/X86/coalesce-cfg.ll [new file with mode: 0644]
llvm/test/DebugInfo/assignment-tracking/X86/coalesce-options.ll [new file with mode: 0644]
llvm/test/DebugInfo/assignment-tracking/X86/coalesce-simple.ll [new file with mode: 0644]
llvm/test/DebugInfo/assignment-tracking/X86/lower-to-value.ll
llvm/test/DebugInfo/assignment-tracking/X86/mem-loc-frag-fill-cfg.ll
llvm/test/DebugInfo/assignment-tracking/X86/mem-loc-frag-fill.ll
llvm/test/DebugInfo/assignment-tracking/X86/nested-loop-frags.ll
llvm/test/DebugInfo/assignment-tracking/X86/use-known-value-at-early-mem-def-2.ll