[SLP] Add basic self consistency asserts into scheduling
The idea here is to have a verify routine we can call during scheduling to ensure broken invariants are reported. The intent is to help in debugging scheduling bugs. At the moment, only the most basic properties are checked as adding several I thought held reported failures.
This commit is contained in:
@@ -2463,6 +2463,18 @@ private:
|
||||
Lane = -1;
|
||||
}
|
||||
|
||||
/// Verify basic self consistency properties
|
||||
void verify() {
|
||||
if (hasValidDependencies()) {
|
||||
assert(UnscheduledDeps <= Dependencies && "invariant");
|
||||
}
|
||||
|
||||
if (IsScheduled) {
|
||||
assert(isSchedulingEntity() && UnscheduledDeps == 0 &&
|
||||
"unexpected scheduled state");
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if the dependency information has been calculated.
|
||||
bool hasValidDependencies() const { return Dependencies != InvalidDeps; }
|
||||
|
||||
@@ -2712,6 +2724,15 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
/// Verify basic self consistency properties of the data structure.
|
||||
void verify() {
|
||||
if (!ScheduleStart)
|
||||
return;
|
||||
|
||||
for (auto *I = ScheduleStart; I != ScheduleEnd; I = I->getNextNode())
|
||||
doForAllOpcodes(I, [](ScheduleData *SD) { SD->verify(); });
|
||||
}
|
||||
|
||||
void doForAllOpcodes(Value *V,
|
||||
function_ref<void(ScheduleData *SD)> Action) {
|
||||
if (ScheduleData *SD = getScheduleData(V))
|
||||
@@ -7904,6 +7925,11 @@ void BoUpSLP::scheduleBlock(BlockScheduling *BS) {
|
||||
}
|
||||
assert(NumToSchedule == 0 && "could not schedule all instructions");
|
||||
|
||||
// Check that we didn't break any of our invariants.
|
||||
#ifdef EXPENSIVE_CHECKS
|
||||
BS->verify();
|
||||
#endif
|
||||
|
||||
// Avoid duplicate scheduling of the block.
|
||||
BS->ScheduleStart = nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user