This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Change a couple of instances of LiveRegs.contains to !LiveRegs.available
ClosedPublic

Authored by dmgreen on Aug 4 2021, 5:55 AM.

Details

Summary

This changes a couple of calls to LiveRegs.contains to !LiveRegs.available, one in Thumb1FrameLoweringInfo (which modifies a test to look more correct to me, given r7 should be the frame pointer so is not available), and another in the ARMLoadStoreOptimizer, that I don't have a test for, it was just found by inspection.

Diff Detail

Event Timeline

dmgreen created this revision.Aug 4 2021, 5:55 AM
dmgreen requested review of this revision.Aug 4 2021, 5:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 4 2021, 5:55 AM
SjoerdMeijer added inline comments.Aug 5 2021, 2:51 AM
llvm/lib/Target/ARM/Thumb1FrameLowering.cpp
588

I have not looked very long at this (and the context how this is used), but if we want to find an available temporary, then the check:

"the live physical registers UsedRegs does not contain Reg"

sounds about right to me.

So can you perhaps explain the problem and why this is wrong?

dmgreen added inline comments.Aug 6 2021, 6:33 AM
llvm/lib/Target/ARM/Thumb1FrameLowering.cpp
588

The docs of contains() say it all:

/// Note: Returns false if just some sub registers are live, use available()
/// when searching a free register.

available() will also check for reserved regs, like r7 under the thumb1 test. The reason I was looking at this was because of the subreg liveness. RDA needed a number of fixes to make it correct. This case possibly does not matter as much, with GPR regs not having subregs, but available() seems like the more correct function to use.

SjoerdMeijer accepted this revision.Aug 6 2021, 6:55 AM
SjoerdMeijer added inline comments.
llvm/lib/Target/ARM/Thumb1FrameLowering.cpp
588

Ah, thanks, makes sense!

Looks like a good fix to me!

This revision is now accepted and ready to land.Aug 6 2021, 6:55 AM
This revision was landed with ongoing or failed builds.Aug 10 2021, 1:53 AM
This revision was automatically updated to reflect the committed changes.