Skip to content

Commit 52c1162

Browse files
committed
[RISCV][VLOPT] Clear DemandedVLs for each invocation of runOnMachineFunction
I was running into failed assertions of `isCandidate(UserMI)` in `getMinimumVLForUser`, but only occurring with `-enable-machine-outliner=never`. I believe this is a red herring, and it just so happens the memory allocation pattern on my machine exposed the bug with that flag. DemandedVLs is never cleared, which means it accumulates more MachineInstr pointer keys over time, and it's possible that when e.g. running on function 'b', a MachineInstr pointer points to the same memory location used for a candidate in 'a'. This causes the assertion to fail. Comment left on #124530 with more information.
1 parent a5e969a commit 52c1162

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Diff for: llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,7 @@ bool RISCVVLOptimizer::tryReduceVL(MachineInstr &MI) {
13341334
}
13351335

13361336
bool RISCVVLOptimizer::runOnMachineFunction(MachineFunction &MF) {
1337+
assert(DemandedVLs.size() == 0);
13371338
if (skipFunction(MF.getFunction()))
13381339
return false;
13391340

@@ -1372,5 +1373,6 @@ bool RISCVVLOptimizer::runOnMachineFunction(MachineFunction &MF) {
13721373
}
13731374
}
13741375

1376+
DemandedVLs.clear();
13751377
return MadeChange;
13761378
}

0 commit comments

Comments
 (0)