In response to https://groups.google.com/g/llvm-dev/c/dggTGzLIezw/m/AYA97MVcAwAJ
I had a go at extending the llvm-reduce framework to also be able to do reduction on MIR.
For convenience and more easy integration into our downstream repository (without breaking current llvm-reduce) the source code of llvm-reduce has been copied into llvm-mir-reduce and then modified instead of modified in place on a separate branch. So I think the end goal should be integration with llvm-reduce but for now during initial development this is how it is.
Actually the differences in the existing code are really minor as can be seen by recursively diffing the two directories as in
$ meld llvm-reduce/ llvm-mir-reduce/
It is mostly about wrapping Module inside a made up class MyMachineModule that contains a Module as well as MachineFunction and then provide methods and functions to import, export and clone these.
Previously LLVM has been lacking utility functions to clone MachineFunctions and this is something that I have brought up as well (https://groups.google.com/g/llvm-dev/c/kTD5t_iHhTM/m/nLMuQOGgAwAJ) because I think it could be useful in other scenarios. The one I have implemented here is not perfect but it does seem to work for this purpose and if there are other needs maybe it could be evolved and properly integrated into lib/CodeGen.
So I guess there are a few questions to answer here
Should this tool be upstreamed?Should it be integrated with llvm-reduce?How should we handle/wrap the Module and MachineFunctions?Should we provide generic MahcineFunction cloning support?
Thoughts and comments please!
is it possible to do this via FileCheck like the other tests?