This is an archive of the discontinued LLVM Phabricator instance.

llvm-reduce: Handle cloning MachineFrameInfo and stack objects
ClosedPublic

Authored by arsenm on Apr 14 2022, 7:21 AM.

Details

Summary

This didn't work at all before, and would assert on any frame
index. Also copy the other fields, which I believe should cover
everything. There are a few that are untested since MIR serialization
is apparently still missing them.

Diff Detail

Event Timeline

arsenm created this revision.Apr 14 2022, 7:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 14 2022, 7:21 AM
arsenm requested review of this revision.Apr 14 2022, 7:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 14 2022, 7:21 AM
Herald added a subscriber: wdng. · View Herald Transcript

wdyt about testing MF cloning directly rather than indirectly via llvm-reduce? perhaps via unit tests?

wdyt about testing MF cloning directly rather than indirectly via llvm-reduce? perhaps via unit tests?

Unit tests are more work. It's easier to have a standalone MIR test input. The only problem there is the remaining pieces which MIR serialization doesn't cover

MatzeB accepted this revision.Apr 14 2022, 8:58 AM

I fear that having the cloning code in tools/llvm-reduce makes it easy for people to miss when they add new fields to MachineFrameInfo. Have you considered adding a MachineFrameInfo::clone(...) method instead so the code lives closer to the rest of MachineFrameInfo? (same comment probably applies to more of the machine function cloning code, so we can move the code around in an independent commit or another time...)

Either way LGTM

llvm/tools/llvm-reduce/ReducerWorkItem.cpp
81–82

Maybe this should just be announced in the commit message. Having a FIXME comment here feels slightly off to me since we're not gonna add a test into this particular file or at this line.

98–99
111

as above

130
This revision is now accepted and ready to land.Apr 14 2022, 8:58 AM

I fear that having the cloning code in tools/llvm-reduce makes it easy for people to miss when they add new fields to MachineFrameInfo. Have you considered adding a MachineFrameInfo::clone(...) method instead so the code lives closer to the rest of MachineFrameInfo?

Yes. The ugly point on that is you still need something to map between the new and old function block references, which feels like an llvm-reduce specific piece you can't avoid. I guess it could use the original blocks and llvm-reduce can post-process them