[PATCH] D118453: [DebugInfo][InstrRef][NFC] Free resources at an earlier stage, to avoid double accounting

Jeremy Morse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 28 04:38:31 PST 2022


jmorse created this revision.
jmorse added reviewers: StephenTozer, Orlando, TWeaver.
Herald added a subscriber: hiraditya.
jmorse requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch releases some memory from InstrRefBasedLDV earlier that it would otherwise. The underlying problem is:

- We store a big table of "live in values for each block",
- We translate that into DBG_VALUE instructions in each block,

And both exist in memory at the same time, which needlessly doubles that information. The most of what this patch does is: as we progressively translate live-in information into DBG_VALUEs, we free the variable-value / machine-value tracking information as we go, which significantly reduces peak memory.

Rolled into this patch too: once we've build the per-block-live-in information, call "clear" on the collection of VLocTracker objects. These store all the variable assignments that happen in a block, there's no need to keep that around once we've made use of them. Doing so exposes another flaw: it seems we were spuriously collecting all variable assignments for a second time, into the final blocks assignment records. Stop this by setting the "VTracker" field of InstrRefBasedLDV to null, and in a couple of locations fix the condition for recording some information.

As a final twiddle, change a DenseMap into a SmallDenseMap to avoid what might be an un-necessary initial allocation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118453

Files:
  llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
  llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118453.403966.patch
Type: text/x-patch
Size: 3867 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220128/7ae16f25/attachment.bin>


More information about the llvm-commits mailing list