This is an archive of the discontinued LLVM Phabricator instance.

[nfc][mlgo][regalloc] Cache live interval feature components
ClosedPublic

Authored by mtrofin on Jan 31 2022, 7:23 PM.

Details

Summary

Lazily cache the feature components of a LiveInterval.

Diff Detail

Event Timeline

mtrofin created this revision.Jan 31 2022, 7:23 PM
mtrofin requested review of this revision.Jan 31 2022, 7:23 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 31 2022, 7:23 PM

Gentle reminder - I don't think this change is too controversial, but lmk if advisors owning VRAIs seems too gauche.

MatzeB added inline comments.Feb 2 2022, 6:56 PM
llvm/lib/CodeGen/MLRegallocEvictAdvisor.cpp
252–255

Isn't this only ever computed once per live interval? I don't see any code computing this a 2nd time making it necessary to invalidate a cache...

The only user of this function is VirtRegAuxInfo::calculateSpillWeightsAndHints computing the initial spill weights when initializing the regalloc; and LiveRangeEdit::calculateRegClassAndHint which calls this function only for the newly created live intervals.

Why would you need to invalidate a cache then?

mtrofin marked an inline comment as done.Feb 2 2022, 8:08 PM
mtrofin added inline comments.
llvm/lib/CodeGen/MLRegallocEvictAdvisor.cpp
252–255

Oh, true - so much simpler.

(separately, I wonder if I can remove setWeight and just ctor the LI with it pre-calculated)

mtrofin updated this revision to Diff 405516.Feb 2 2022, 8:08 PM
mtrofin marked an inline comment as done.

simplification

mtrofin edited the summary of this revision. (Show Details)Feb 3 2022, 12:40 PM
yundiqian accepted this revision.Feb 3 2022, 4:17 PM
This revision is now accepted and ready to land.Feb 3 2022, 4:17 PM
This revision was landed with ongoing or failed builds.Feb 3 2022, 5:02 PM
This revision was automatically updated to reflect the committed changes.