[LLVMdev] How to force a MachineFunctionPass to be the last one ?
atrick at apple.com
Tue Jan 21 15:20:45 PST 2014
On Jan 21, 2014, at 2:20 PM, sebastien riou <matic at nimp.co.uk> wrote:
> I would like to execute a MachineFunctionPass after all other passes
> which modify the machine code.
> In other words, if we call llc to generate assembly file, that pass
> should run right before the "Assembly Printer" pass.
> Is there any official way to enforce this ?
This makes sense and has come up before in discussions. I can envision a set of analyses that need to run after all MI modification but before asm printing. The StackMapLiveness pass is one such example. No enforcement mechanism exists yet, but it’s safe to say that nothing with modify MI after the addPreEmitPasses hook. For now you can just schedule your pass at the end with comments.
We could introduce a fake MI analysis that should be invalidated by any pass that mutates the MI. Then check that it’s valid during code emission. That part is trivial.
I think the real issue is that MC lowering can potentially change opcodes, so you can never really do this reliably in general :(
I’m not sure how fixable that problem is. Maybe others can provide more suggestions.
More information about the llvm-dev