[PATCH] D110630: [DebugInfo][InstrRef] Use PHI placement utilities for variable-value calculations

Jeremy Morse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 28 07:50:45 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 patch is very similar to D110173 <https://reviews.llvm.org/D110173>, but for variable values rather than machine values. This is for the second instr-ref problem, calculating the correct variable value on entry to each block. As in D110173 <https://reviews.llvm.org/D110173>, rather than using Jeremys incorrect lattice solution, we use the existing LLVM tooling to place PHI values at control flow merges, and then use value propagation to eliminate un-necessary ones. The only real difference with the machine-value implementation is that we must pick a location for variable PHI values, i.e. when the variable has two different values in predecessors to the block, try to find a register where those same values merge together. That's implemented in pickVPHILoc. Again, I've written a bunch of unit tests to demonstrate and stimulate what different parts of this implementation should be doing.

Into the specifics: I've moved the VLocTracker class into the InstrRefBasedImpl header, so that we can test with it. I's just a collection containing the variable-value transfer function for each block. The DbgValue class, storing the "current value "of a variable while solving, grows a "VPHI" kind to represent variable-value PHIs that haven't been eliminated (yet).

Quite a lot of vlocJoin gets deleted: we no longer try to pick the right variable value and whether there should be a PHI in this function. Instead, PHIs are pre-placed with the LLVM IDF calculator, and vlocJoin just tries to eliminate them. Picking a location for a PHI is handled immediately afterwards by calling pickVPHILoc. The transfer function evaluation doesn't change at all.

In the unit-tests, I've re-factored creation of the block layouts into their own function so that they can be shared, and re-numbered the MachineBasicBlock pointer variables to be zero based, to avoid future confusion. As with the machine-location testing, I can't guarantee the unit tests achieve wonderful coverage, but they're a lot better than nothing and should demonstrate what's supposed to be happening in various scenarios.

The regression test added used to cause an infinite loop in the old lattice arrangement, because it would whip back and forth between trying to have a PHI in $rdx then $rcx, and back again. As I'd already figured out this was basically trying to do SSA construction, it probably could have been fixed... but better to refresh everything in terms that can actually be understood.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110630

Files:
  llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
  llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
  llvm/test/DebugInfo/MIR/InstrRef/pick-vphi-in-shifting-loop.mir
  llvm/unittests/CodeGen/InstrRefLDVTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110630.375573.patch
Type: text/x-patch
Size: 133872 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210928/5715db1f/attachment.bin>


More information about the llvm-commits mailing list