[all-commits] [llvm/llvm-project] 8e56a1: [Assignment Tracking] Improve removeRedundantDbgLo...

Orlando Cazalet-Hyams via All-commits all-commits at lists.llvm.org
Wed Mar 29 08:00:19 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8e56a196fb5c26e556ac267986868a3f63b7c486
      https://github.com/llvm/llvm-project/commit/8e56a196fb5c26e556ac267986868a3f63b7c486
  Author: OCHyams <orlando.hyams at sony.com>
  Date:   2023-03-29 (Wed, 29 Mar 2023)

  Changed paths:
    M llvm/include/llvm/IR/DebugInfoMetadata.h
    M llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
    M llvm/test/DebugInfo/assignment-tracking/X86/nested-loop-frags.ll
    A llvm/test/DebugInfo/assignment-tracking/X86/remove-redundant-defs-bwd-scan.ll
    M llvm/test/DebugInfo/assignment-tracking/X86/untagged-store-frag.ll

  Log Message:
  -----------
  [Assignment Tracking] Improve removeRedundantDbgLocsUsingBackwardScan

`removeRedundantDbgLocsUsingBackwardScan` removes redundant dbg loc definitions
by scanning backwards through contiguous sets of them (a "wedge"), removing
earlier (in IR order terms) defs for fragments of variables that are defined
later in the wedge.

In this patch we use a `Bitvector` for each variable to track which bits have
definitions to more accurately determine whether a loc def is redundant. This
patch increases compile time by itself, but reduces it when combined with the
follow-up patch.

Reviewed By: jmorse

Differential Revision: https://reviews.llvm.org/D146978


  Commit: d4879d769095d76ddf9484c50661feac96ce525a
      https://github.com/llvm/llvm-project/commit/d4879d769095d76ddf9484c50661feac96ce525a
  Author: OCHyams <orlando.hyams at sony.com>
  Date:   2023-03-29 (Wed, 29 Mar 2023)

  Changed paths:
    M llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
    A llvm/test/DebugInfo/assignment-tracking/X86/coalesce-cfg.ll
    A llvm/test/DebugInfo/assignment-tracking/X86/coalesce-options.ll
    A llvm/test/DebugInfo/assignment-tracking/X86/coalesce-simple.ll
    M llvm/test/DebugInfo/assignment-tracking/X86/lower-to-value.ll
    M llvm/test/DebugInfo/assignment-tracking/X86/mem-loc-frag-fill-cfg.ll
    M llvm/test/DebugInfo/assignment-tracking/X86/mem-loc-frag-fill.ll
    M llvm/test/DebugInfo/assignment-tracking/X86/nested-loop-frags.ll
    M llvm/test/DebugInfo/assignment-tracking/X86/use-known-value-at-early-mem-def-2.ll

  Log Message:
  -----------
  [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


Compare: https://github.com/llvm/llvm-project/compare/28858d5902f8...d4879d769095


More information about the All-commits mailing list