I encountered some problems with SIFixWWMLiveness when WWM is in a loop:
- It sometimes gave invalid MIR where there is some control flow path to the new implicit use of a register on EXIT_WWM that does not pass through any def.
- There were lots of false positives of registers that needed to have an implicit use added to EXIT_WWM.
- Adding an implicit use to EXIT_WWM (and adding an implicit def just before the WWM code, which I tried in order to fix (1)) caused lots of the values to be spilled and reloaded unnecessarily.
This commit is a rework of SIFixWWMLiveness, with the following changes:
- Instead of considering any register with a def that can reach the WWM code and a def that can be reached from the WWM code, it now considers three specific cases that need to be handled.
- A register that needs liveness over WWM to be synthesized now has it done by adding itself as an implicit use to defs other than the dominant one.
Also added the following fixmes:
FIXME: We should detect whether a register in one of the above
categories is already live at the WWM code before deciding to add the
implicit uses to synthesize its liveness.
FIXME: I believe this whole scheme may be flawed due to the possibility
of the register allocator doing live interval splitting.
Change-Id: Ie7fba0ede0378849181df3f1a9a7a39ed1a94a94