https://bugs.llvm.org/show_bug.cgi?id=36587 discovered a set of used (preserved) pregs in function that was corrupt which led to wrong code.
This patch adds a check in the MachineVerifier that makes sure that any registers defined by any instruction in the current function which are call-preserved have all their aliases marked as used in function in the set produced by RegUsageInfoCollector.
As it is now no verification will be done if CallPreservedMask is nullptr (this happens with a lot of AMDGPU tests).
This test fails now: LLVM :: CodeGen/AMDGPU/function-returns.ll
The test in 36587 fails like:
`# End machine code for function fn2.
- Bad machine code: Defined register (alias) not in RegUsageInfo: R0H ***
- function: fn2
- basic block: %bb.1 (0x50f3540)
- instruction: renamable $r0d = LGHI 0
LLVM ERROR: Found 1 machine code errors.`
I would have named it verifyPreservedMask or something.
I would expect a verifyUsedPhysReg to work on UsedPhysRegMask not the PreservedMask one.