This is an archive of the discontinued LLVM Phabricator instance.

llvm-reduce: Add reduction pass to remove regalloc hints
ClosedPublic

Authored by arsenm on Apr 20 2022, 8:55 AM.

Details

Summary

I'm a bit confused by what's actually stored for the allocation
hints. The MIR parser only handles the "simple" case where there's a
single hint. I don't really understand the assertion in
clearSimpleHint, or under what circumstances there are multiple hint
registers.

Diff Detail

Event Timeline

arsenm created this revision.Apr 20 2022, 8:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2022, 8:55 AM
Herald added a subscriber: mgorny. · View Herald Transcript
arsenm requested review of this revision.Apr 20 2022, 8:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2022, 8:55 AM
Herald added a subscriber: wdng. · View Herald Transcript

As a general thought, I wonder if it would be wise to keep the MIR specific reducer passes separate from the IR ones. Either by directory or file naming conventions.

llvm/tools/llvm-reduce/deltas/ReduceVirtualRegisters.h
11

Comment needs to be updated.

arsenm updated this revision to Diff 424187.Apr 21 2022, 6:52 AM

Fix comment. Also not sure why every file likes to repeat this style of comment in the source and header

As a general thought, I wonder if it would be wise to keep the MIR specific reducer passes separate from the IR ones. Either by directory or file naming conventions.

I've thought about that and will probably move them into a subdirectory at some point

I'm a bit confused by what's actually stored for the allocation hints. The MIR parser only handles the "simple" case where there's a single hint. I don't really understand the assertion in clearSimpleHint, or under what circumstances there are multiple hint registers.

I'm not super familiar with the regalloc hints off-hand. But it seems ARM is the only target using target-specific regalloc hints. You can search for ARMRI::RegPairEven, ARMRI::RegPairOdd, ARMRI::RegLR there. Anyway assuming they are indeed just "hints" then it should be fine to drop them...

It seems to me that clearing a hint may work with setRegAllocationHint(vreg, 0, Register()). Though maybe it would be best to create a new clearRegAllocationHint(...) API for this to make it more explicit, what do you think?

LGTM (use setRegAllocationHint or add a new clearRegAllocationHint API at your discretion).

MatzeB accepted this revision.Apr 26 2022, 8:47 PM
This revision is now accepted and ready to land.Apr 26 2022, 8:47 PM

I'm a bit confused by what's actually stored for the allocation hints. The MIR parser only handles the "simple" case where there's a single hint. I don't really understand the assertion in clearSimpleHint, or under what circumstances there are multiple hint registers.

I'm not super familiar with the regalloc hints off-hand. But it seems ARM is the only target using target-specific regalloc hints. You can search for ARMRI::RegPairEven, ARMRI::RegPairOdd, ARMRI::RegLR there. Anyway assuming they are indeed just "hints" then it should be fine to drop them...

It seems to me that clearing a hint may work with setRegAllocationHint(vreg, 0, Register()). Though maybe it would be best to create a new clearRegAllocationHint(...) API for this to make it more explicit, what do you think?

LGTM (use setRegAllocationHint or add a new clearRegAllocationHint API at your discretion).

clearSimpleHint already exists (and is used here) and as far as I can tell clears all hints, so I don't understand the naming

clearSimpleHint already exists (and is used here) and as far as I can tell clears all hints, so I don't understand the naming

Renaming that function to clearHint() and dropping the assert sounds good to me.