This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo][Docs] Add corrected docs for how InstrRefBasedLDV works
AbandonedPublic

Authored by jmorse on May 10 2021, 3:05 AM.

Details

Reviewers
None
Group Reviewers
debug-info
Summary

Hello debug-info folks!

Some may have been wondering, "What happened to that variable-location rewrite that Jeremy was trying to sell?". It was a bit delayed, and my thought process went like this:

  • Hey cool, this new LiveDebugValues is SSA construction at the end of compilation!
  • I didn't know you could do SSA construction just with lattices!
  • Ah... you actually can't, so I've missed something in my understanding,
  • Curses.

As it happens, I was keeping an extra piece of information for each block that meant the analysis didn't qualify as a normal dataflow algorithm. I've refreshed my understanding and written more docs on what's happening, plus three worked examples. The short summary is:

  • It's SSA construction, where the hard part is identifying PHIs,
  • We have to eliminate all dead PHIs to get accurate variable locations,
  • We use value propagation the eliminate most dead PHIs,
  • And an RPO-traversal algorithm to eliminate dead PHIs at loop heads.

Reassuringly, mem2reg does the same thing, but in a different way, to eliminate dead PHIs.

Now that this is sorted out, I'll be much happier landing patches on this topic.

The diagrams are written in tikz, I've been using the "tikzit" environment. I'm not sure what LLVM needs in terms of the "original source" for diagrams like this.

Diff Detail

Event Timeline

jmorse requested review of this revision.May 10 2021, 3:05 AM
jmorse created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptMay 10 2021, 3:05 AM

NB: a pre-render of the text and diagrams can be found here:

https://github.com/jmorse/llvm-project/blob/publish-master/llvm/docs/InstrRefLiveDebugValues.md

I only had time for a few superficial comments so far and this deserves an in-depth read, but I greatly appreciate the time and effert that went into putting this to paper!

llvm/docs/BadlyBehaved.tikz
2

Might be nice to add the command line that produced the png as a comment here.
Maybe more LLVM readers are familiar with Graphviz dote files, since LLVM produces them, but I don't have a strong opinion.

llvm/docs/InstrRefLiveDebugValues.md
3

References to old and new don't usually age well — could we just call them by name?

12

Checked-in documentation should probably not be written from a personal point of view. It might be better to take a neutral stance and sound like it's just describing facts.

20

It might be best not to directly link to a differently licensed project.

24

of

jmorse updated this revision to Diff 346449.May 19 2021, 7:15 AM

Adjust wording from review; I've added a 'tikzrender.tex' latex header and instructions on how to produce a png from a .tikz diagram. Alas, I'm more familiar with tikz than graphviz.

Rather than link to gcc, I've linked to a write-up of the kind of "deferring analysis until later" scenario I think this moves us towards.

myhsu added a subscriber: myhsu.Aug 2 2021, 3:10 PM
jmorse abandoned this revision.Nov 10 2021, 10:43 AM

Superseded by D113586 -- my Rube Goldberg machine for PHI placement isn't needed now that instr-ref is using existing PHI placement tools, so there wasn't much point resurrecting this.