Pulled out of D47637, which was based off some internal work I did years ago but got lost in the upstreaming process.
This patch adds a SubtargetEmitter::CheckSchedClassTables method to verify the state of the scheduler classes. A command line switch "-check-sched-class-table" is added, which is enabled by default for EXPENSIVE_CHECKS builds.
So far this just adds checks for unnecessary overrides of base classes (which typically end up causing bloat in the generated tables), but future patches will add additional checks similar to earlier versions of D47637 and D48222.
The number of unnecessary overrides that are listed are quite extensive (warnings are currently found in the AMDGPU, ARM, AArch64, PowerPC and X86 targets), I'm not convinced they need to be addressed before this patch is committed, although the spam in EXPENSIVE_CHECKS builds is pretty large, but I'm happy to help create bugs/patches to fix them first if reviewers would prefer it.
Sorry - I should have removed the "NumReadAdvanceEntries == 0" entry, it was just an experiment