This is an archive of the discontinued LLVM Phabricator instance.

llvm-reduce: Add cloning of target MachineFunctionInfo
ClosedPublic

Authored by arsenm on Apr 18 2022, 11:21 AM.

Details

Summary

MIR support is totally unusable for AMDGPU without this, since the set
of reserved registers is set from fields here.

Add a clone method to MachineFunctionInfo. This is a subtle variant of
the copy constructor that is required if there are any MIR constructs
that use pointers. Specifically, at minimum fields that reference
MachineBasicBlocks or the MachineFunction need to be adjusted to the
values in the new function.

Diff Detail

Event Timeline

arsenm created this revision.Apr 18 2022, 11:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 18 2022, 11:21 AM
arsenm requested review of this revision.Apr 18 2022, 11:21 AM

Having to touch all these target specific files seems a bit unfortunate but maybe that is the way it has to be.

MatzeB accepted this revision.Apr 26 2022, 9:18 PM

I wonder if we wouldn't be better off by just adding an implementation into the baseclass that does return nullptr; and then abort the llvm-reduce process? That way implementing a proper clone() function becomes a problem for the individual target maintainers when they want to use llvm-reduce and we should get more complete/correct implementations.

That said I don't care too deeply either way. So LGTM leaving the return nullptr change to your discretion.

This revision is now accepted and ready to land.Apr 26 2022, 9:18 PM

I wonder if we wouldn't be better off by just adding an implementation into the baseclass that does return nullptr; and then abort the llvm-reduce process? That way implementing a proper clone() function becomes a problem for the individual target maintainers when they want to use llvm-reduce and we should get more complete/correct implementations.

That is what this does, it just turned out to be not very difficult to implement for every target once frame index values are stable