This patch adds a simple verifier that tracks type indices being touched by legalization rules' builders.
Every target will now have an opportunity to call LegalizerInfo::verify(...) at the end of its derived LegalizerInfo's constructor and check there are no obvious mistakes like checking only first type for an opcode that has more than one type index and therefore implicitly declaring any type for the second (and higher) type index legal.
The check is only ran in assert builds and should have very minor performance impact in assert builds and none in release builds.
This patch also doesn't make the verification errors fatal, only produces an error message, there is a follow up patch that does.
This is inspired by the discussion at https://reviews.llvm.org/D44704, please take a look there for more info on motivation.
This patch includes 2 commits:
the first is described above, it does not add LegalizerInfo::verify(...) calls to target-specific legalizers;
the second one has the following message:
[GlobalISel][AArch64] LegalizerInfo verifier: Adding LegalizerInfo::verify(...) call w/o fixing bugs This is to make it clear what kind of bugs the LegalizerInfo::verifier is able to catch and test its output
I also have an NFC commit planned to get in before this patch with the following commit message:
[GlobalISel][Legalizer] LegalizerInfo NFC, mostly reducing LegalizeRuleSet's methods' inter-dependecies Making LegalizeRuleSet's implementation a little more dumb and straightforward to make it easier to read and change, in particular in order to add the initial version of LegalizerInfo verifier
"Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp."
Greenspun's tenth rule of programming. 1993