[PATCH] D111716: [DebugInfo][InstrRef] Avoid un-necessary densemap copies and comparisons

Jeremy Morse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 13 07:41:38 PDT 2021


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 is a plain and simple performance patch: InstrRefBasedLDV passes uses three distinct DenseMaps when calculating what variable values are in a block: two "long term" dense maps, and one "working" dense map. The live-ins are:

- Placed into the working set, as vlocJoin works out what each variables value should be,
- Copied into the "long term" live-in storage back in buildVLocValueMap,
- The working set has its values updated by the blocks transfer function,
- The working set is copied into the blocks live-out DenseMap.

This works well enough, but it involves two dense map comparisons and two dense map assignments, when each of the live-in / live-out dense maps are updated. For scopes with a small number of variables, this can take a large amount of time, seeing how (I think?) the initial DenseMap allocation is 64 elements. We could pay with SmallDenseMaps, however instead, lets just reduce the total number of densemaps. We can update live-ins and live-outs in-place, as appropriate, avoiding the comparisons and copies.

Practically, this means passing fewer bits of information around. Every time we make an assignment to a live-in or live-out because vlocJoin (or the transfer function) has changed it, we have to do an explicit comparison to see whether we're changing the value. Otherwise, everything works as before.

This claws back another slice of performance: http://llvm-compile-time-tracker.com/compare.php?from=bc07cf76a31fa769786d6631fe25586bd1396c34&to=231cbb7cbd13e01cf81fa97db441582af2efbbb7&stat=instructions


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111716

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111716.379372.patch
Type: text/x-patch
Size: 28812 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211013/292c9bc8/attachment.bin>


More information about the llvm-commits mailing list