This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] MachinePostRAUpdater
AbandonedPublic

Authored by samparker on Dec 19 2019, 2:44 AM.

Details

Reviewers
None
Summary

Introduce a new class that acts as a wrapper around ReachingDefAnalysis that can be used to track changes and still query use-def chains. It's primary purpose is to enable the insertion, removal and movement of machine instructions. This replaces how we were using RDA in ARMLowOverheadLoops.
The initialisation code for RDA has been split up a bit so that we can re-run the traversal after making modifications to the function.

Diff Detail

Event Timeline

samparker created this revision.Dec 19 2019, 2:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 19 2019, 2:44 AM
samparker edited the summary of this revision. (Show Details)Dec 19 2019, 2:45 AM
samparker updated this revision to Diff 234707.Dec 19 2019, 5:49 AM
  • isSafeToRemove now looks at the use-def chain of the block and returns yes/no along with all the instructions that should be removed. For low-overhead loops, this is means that we don't have to explicitly check for LR users within the loop and the updater will look at copies so we can remove them too! The new test case is an example where LR copies previously prevented the transform.

Good stuff!

I haven't looked at details yet, but wanted to ask a high-level dumb question first. Essentially, this is DCE on MachineFunctions/MachineLoops. Just floating an idea, and you can correct me where I go wrong. Do you perhaps see any benefits in making this is a separate pass? I was thinking that by separating the concerns (i.e. LowOverhead loops, and cleaning-up and DCE), we can have a clean-up pass running after low-overhead loops, with possibly the benefit being that low-overhead loops does not have to deal with any of the cleanup and bookkeeping.

No, another pass won't help here. The point of this class is to allow transforms to use ReachingDefAnalysis while changing the code at the same time, not something a pass is useful for. But it should indeed be useful for DCE. ReachingDefAnalysis could(?) be modified to re-evaluate new instructions, but I don't think general queries about being able to move instructions fits into the analysis. In the context of low-overhead loops, we still need specific information from that analysis, such as instructions to ignore, to be able to do anything useful. For instance, we have cases where we want to remove 'redundant' mov instructions but, without knowing that the loop control instructions get removed, then those movs wouldn't be dead according to this class.

samparker updated this revision to Diff 235147.Dec 23 2019, 8:24 AM
samparker edited the summary of this revision. (Show Details)

Rebased.

samparker updated this revision to Diff 240193.Jan 24 2020, 7:32 AM
samparker edited the summary of this revision. (Show Details)
  • Rebased.
  • Broke up some of the initialisation code in RDA so we can re-run after finalization.
samparker retitled this revision from [CodeGen] WIP MachinePostRAUpdater to [CodeGen] MachinePostRAUpdater.Jan 24 2020, 7:36 AM
samparker abandoned this revision.Jan 27 2020, 3:36 AM

I've extracted the immediately useful changes into D73460, but it doesn't include the RDA initialisation changes. With those changes, I think being able to re-run the analysis is also likely to make this wrapper redundant.