[llvm] [VPlan] Speed up VPSlotTracker by using ModuleSlotTracker (PR #139881)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Wed May 14 07:01:03 PDT 2025
================
@@ -382,14 +383,25 @@ class VPSlotTracker {
/// Number to assign to the next VPValue without underlying value.
unsigned NextSlot = 0;
+ /// Cache slot indexes to avoid recomputing them on each printAsOperand call.
+ std::unique_ptr<ModuleSlotTracker> MST;
+
void assignName(const VPValue *V);
void assignNames(const VPlan &Plan);
void assignNames(const VPBasicBlock *VPBB);
public:
VPSlotTracker(const VPlan *Plan = nullptr) {
- if (Plan)
+ if (Plan) {
+ // This check is required to support unit tests with incomplete IR.
+ if (Function *F =
+ Plan->getScalarHeader()->getIRBasicBlock()->getParent()) {
+ Module *M = F->getParent();
+ MST = std::make_unique<ModuleSlotTracker>(M);
----------------
david-arm wrote:
The version of `incorporateFunction` I'm looking at is this:
```
void ModuleSlotTracker::incorporateFunction(const Function &F) {
// Using getMachine() may lazily create the slot tracker.
if (!getMachine())
return;
// Nothing to do if this is the right function already.
if (this->F == &F)
return;
if (this->F)
Machine->purgeFunction();
Machine->incorporateFunction(&F);
this->F = &F;
}
```
which looks like it's doing more than setting a couple of values?
https://github.com/llvm/llvm-project/pull/139881
More information about the llvm-commits
mailing list