This patch adds some unit tests for the machine-location transfer-function building parts of InstrRefBasedLDV: i.e., test that if we feed some MIR into the transfer-function building code, does it create the correct transfer function.
There are a number of minor defects that get corrected in the process:
- The unit test was selecting the x86 (i.e. 32 bit) backend rather than x86_64's 64 bit backend,
- COPY instructions weren't actually having their subregister values correctly represented in the transfer function. Subregisters were being defined by the COPY, rather than taking the value in the source register.
All call instructions were clobbering the stack pointer: a recent patch that fiddled with this accidentally inverted the logic.Actually, they were at risk of being clobbered, if an SP subregister was clobbered.
I'll drop inline comments in explaining the different parts.
Otherwise, cosmetically, I've replaced a "getNumAtPos" method with "readMLoc". This is more consistent with the other helper functions for, for example, setting the values in machine locations.
a) the comment here was wrong, but b) it's important that DBG_PHI instructions are interpreted when building the machine-value transfer function. If there are register operands of DBG_PHIs, they and their subregisters should be tracked. We risk building in some assumption that they're not tracked if we don't do it immediately.
(In the past I've allocated some vectors for "all the registers", then found the number of registers being tracked changed later).