Pete Cooper
2014-Jan-22 00:39 UTC
[LLVMdev] How to force a MachineFunctionPass to be the last one ?
On Jan 21, 2014, at 3:20 PM, Andrew Trick <atrick at apple.com> wrote:> > On Jan 21, 2014, at 2:20 PM, sebastien riou <matic at nimp.co.uk> wrote: > >> Hi, >> >> 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.You can add your pass to the end of X86PassConfig::addPreEmitPass() and it will currently be the last thing to run before the asm printer, but I don’t know if thats a guarantee or not. In theory anyone could add something after the call to preEmitPass and before this code FunctionPass *Printer = getTarget().createAsmPrinter(*this, *AsmStreamer); PM.add(Printer); but if they do you can shout loudly :) Thanks, Pete> > -Andy > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Juergen Ributzka
2014-Jan-22 01:12 UTC
[LLVMdev] How to force a MachineFunctionPass to be the last one ?
Please don’t yell at me Pete, but I already did that with the StackMapLiveness pass :P Although the pass only touches STACKMAP and PATCHPOINT instructions, so it shouldn’t be an issue. Cheers, Juergen On Jan 21, 2014, at 4:39 PM, Pete Cooper <peter_cooper at apple.com> wrote:> You can add your pass to the end of > > X86PassConfig::addPreEmitPass() > > and it will currently be the last thing to run before the asm printer, but I don’t know if thats a guarantee or not. > > In theory anyone could add something after the call to preEmitPass and before this code > > FunctionPass *Printer = getTarget().createAsmPrinter(*this, *AsmStreamer); > PM.add(Printer); > > but if they do you can shout loudly :) > > Thanks, > Pete-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140121/668885d1/attachment.html>
Andrew Trick
2014-Jan-22 03:03 UTC
[LLVMdev] How to force a MachineFunctionPass to be the last one ?
On Jan 21, 2014, at 5:12 PM, Juergen Ributzka <juergen at apple.com> wrote:> Please don’t yell at me Pete, but I already did that with the StackMapLiveness pass :P > Although the pass only touches STACKMAP and PATCHPOINT instructions, so it shouldn’t be an issue.That doesn’t really count since we’re only “annotating” the instruction with a register mask. For the purpose of code emission it’s just metadata. -Andy> Cheers, > Juergen > > > On Jan 21, 2014, at 4:39 PM, Pete Cooper <peter_cooper at apple.com> wrote: > >> You can add your pass to the end of >> >> X86PassConfig::addPreEmitPass() >> >> and it will currently be the last thing to run before the asm printer, but I don’t know if thats a guarantee or not. >> >> In theory anyone could add something after the call to preEmitPass and before this code >> >> FunctionPass *Printer = getTarget().createAsmPrinter(*this, *AsmStreamer); >> PM.add(Printer); >> >> but if they do you can shout loudly :) >> >> Thanks, >> Pete >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140121/ca024762/attachment.html>