[RegUsageInfoCollector] Don't mark as saved registers that don't have subregister...
authorQuentin Colombet <quentin.colombet@gmail.com>
Tue, 28 May 2019 23:43:12 +0000 (23:43 +0000)
committerQuentin Colombet <quentin.colombet@gmail.com>
Tue, 28 May 2019 23:43:12 +0000 (23:43 +0000)
commita6f57ad2c9dc1f34f7935ccbddc5fe13ffdc2adc
treee27e5a724e31513727c4519818614aacbc4b5203
parenteb5ee3004f79c97e973025bb524e278a47c595c7
[RegUsageInfoCollector] Don't mark as saved registers that don't have subregister lanes

To determine the list of clobbered registers, the RegUsageInfoCollector pass
uses the list of callee saved registers provided by the target and then augments
it with the list of registers which have all their subregisters saved. It then
basically does the difference between all the registers and the saved registers
to come up with what is clobbered (plus it checks that the register is defined
within that functions).

The patch fixes a bug where when register does not have any subregister lane,
hence when checking if any of its subregister are not saved, we would find none
and think the register is saved as well.

That's obviously wrong.

The code was actually kind of checking for something like that with the
CoveredBySubRegs bit. What this bit says is that a register is completely
covered by its subregisters.
We required that this bit was set, to check that a register was saved by its
subregister lanes, since without this bit, we potentially would miss to check
some part of the register.

However, this bit is used de facto on registers that don't have any
subregisters (e.g., on ARM) and the code was not prepared for that.

This patch fixes this by checking that a register has subregisters before
declaring it saved when none of its lanes are modified.

llvm-svn: 361901
llvm/lib/CodeGen/RegUsageInfoCollector.cpp
llvm/test/CodeGen/ARM/ipra-reg-usage.ll [new file with mode: 0644]