This is an archive of the discontinued LLVM Phabricator instance.

[Assignment Tracking] Improve removeRedundantDbgLocsUsingBackwardScan
ClosedPublic

Authored by Orlando on Mar 27 2023, 8:49 AM.

Details

Summary

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.

Diff Detail

Event Timeline

Orlando created this revision.Mar 27 2023, 8:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 27 2023, 8:49 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
Orlando requested review of this revision.Mar 27 2023, 8:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 27 2023, 8:49 AM

I think some kind of custom interval map could possibly yield further improvements, but combining the two patches (second one coming shortly) already gives a geomean 0.3% reduction in instructions retired in a CTMark LTO-O3-g build.

Orlando retitled this revision from [Assignment Tracking][NFC] Improve removeRedundantDbgLocsUsingBackwardScan to [Assignment Tracking] Improve removeRedundantDbgLocsUsingBackwardScan.Mar 27 2023, 9:19 AM
jmorse accepted this revision.Mar 28 2023, 3:59 AM

LGTM with one question -- there's a semantic change whereby a debug intrinsic with no fragment is considered as covering the whole variable, right? (I think this is uncontroversial).

As you say, strictly this is doing more work, but to reduce work in the next patch.

llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
2194

Any particular reason for switching from SmallDenseMap to DenseMap -- there's an initial allocation for DenseMaps that's going to mean one additional malloc/free for each block, even if there's little work to be done in it.

2230
This revision is now accepted and ready to land.Mar 28 2023, 3:59 AM

there's a semantic change whereby a debug intrinsic with no fragment is considered as covering the whole variable, right

I don't think there's been a change - I would argue that has always been the case.

llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
2194

No reason - just a typo essentially I think. I will change it back.

I don't think there's been a change - I would argue that has always been the case.

Righty-ho, I just missed it then, LGTM

This revision was automatically updated to reflect the committed changes.
Orlando marked an inline comment as done.