diff options
author | Quentin Colombet <quentin.colombet@gmail.com> | 2019-05-28 23:43:12 +0000 |
---|---|---|
committer | Quentin Colombet <quentin.colombet@gmail.com> | 2019-05-28 23:43:12 +0000 |
commit | a6f57ad2c9dc1f34f7935ccbddc5fe13ffdc2adc (patch) | |
tree | e27e5a724e31513727c4519818614aacbc4b5203 /llvm/lib/CodeGen/RegUsageInfoCollector.cpp | |
parent | eb5ee3004f79c97e973025bb524e278a47c595c7 (diff) | |
download | llvm-a6f57ad2c9dc1f34f7935ccbddc5fe13ffdc2adc.zip llvm-a6f57ad2c9dc1f34f7935ccbddc5fe13ffdc2adc.tar.gz llvm-a6f57ad2c9dc1f34f7935ccbddc5fe13ffdc2adc.tar.bz2 |
[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
Diffstat (limited to 'llvm/lib/CodeGen/RegUsageInfoCollector.cpp')
-rw-r--r-- | llvm/lib/CodeGen/RegUsageInfoCollector.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/RegUsageInfoCollector.cpp b/llvm/lib/CodeGen/RegUsageInfoCollector.cpp index 01c8fcb..3031195 100644 --- a/llvm/lib/CodeGen/RegUsageInfoCollector.cpp +++ b/llvm/lib/CodeGen/RegUsageInfoCollector.cpp @@ -179,12 +179,15 @@ computeCalleeSavedRegs(BitVector &SavedRegs, MachineFunction &MF) { // Add PReg to SavedRegs if all subregs are saved. bool AllSubRegsSaved = true; - for (MCSubRegIterator SR(PReg, &TRI, false); SR.isValid(); ++SR) + bool HasAtLeastOneSubreg = false; + for (MCSubRegIterator SR(PReg, &TRI, false); SR.isValid(); ++SR) { + HasAtLeastOneSubreg = true; if (!SavedRegs.test(*SR)) { AllSubRegsSaved = false; break; } - if (AllSubRegsSaved) + } + if (AllSubRegsSaved && HasAtLeastOneSubreg) SavedRegs.set(PReg); } } |