[PATCH] D118674: [nfc][mlgo][regalloc] Cache live interval feature components

Mircea Trofin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 2 20:08:07 PST 2022


mtrofin marked an inline comment as done.
mtrofin added inline comments.


================
Comment at: llvm/lib/CodeGen/MLRegallocEvictAdvisor.cpp:252-255
+  void calculateSpillWeightAndHint(LiveInterval &LI) override {
+    VirtRegAuxInfo::calculateSpillWeightAndHint(LI);
+    CachedFeatures.erase(LI.reg().id());
+  }
----------------
MatzeB wrote:
> 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? 
Oh, true - so much simpler.

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


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118674/new/

https://reviews.llvm.org/D118674



More information about the llvm-commits mailing list