[llvm] [VPlan] Speed up VPSlotTracker by using ModuleSlotTracker (PR #139881)
Igor Kirillov via llvm-commits
llvm-commits at lists.llvm.org
Wed May 14 06:26:33 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);
----------------
igogo-x86 wrote:
`incorporateFunction` doesn't do any job beyond creating `SlotTracker` and assigning `F`. Any index calculation is delayed until `printAsOperand` is called in `assignName`.
Also, I don't think `VPSlotTracker` exists outside of debug/assert build - all print-related functions are already guarde by this define:
`#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)`
https://github.com/llvm/llvm-project/pull/139881
More information about the llvm-commits
mailing list