Craig Smith
2014-Jun-24 20:33 UTC
[LLVMdev] Any way get debug output of generated assembly from MCJIT without completely redoing CodeGen?
Hello all, I'm trying to hack MCJIT::emitObject to optionally output the corresponding text assembly associated with the object code being emitted (if a debug flag is set in the app/dev environment which is hosting LLVM). I attempted to do this by adding another AsmPrinter pass to the PassManager, but this runs into all sorts of problems because there's only once MCContext and one MachneModuleInfo pass maintaining various state information (MCSections, MCSymbols, etc.) and the two AsmPrinter passes interfere with each other. The only way I've been able to get this to work is to create an entirely separate PassManager, and use addPassesToEmitFile() on it, which will redo the entire CodeGen process again unnecessarily. Does anyone have any ideas/pointers on how I might do this efficiently? This is only for a debugging aid, but I'd like to not have to compile everything twice when it's enabled. Thanks Craig
Eric Christopher
2014-Jun-24 20:57 UTC
[LLVMdev] Any way get debug output of generated assembly from MCJIT without completely redoing CodeGen?
By "debug output" you mean actual debug info or something else? If it's the actual debug info then the answer is no. -eric On Tue, Jun 24, 2014 at 1:33 PM, Craig Smith <craig at ni.com> wrote:> > Hello all, > > I'm trying to hack MCJIT::emitObject to optionally output the corresponding text assembly associated with the object code being emitted (if a debug flag is set in the app/dev environment which is hosting LLVM). > I attempted to do this by adding another AsmPrinter pass to the PassManager, but this runs into all sorts of problems because there's only once MCContext and one MachneModuleInfo pass maintaining various state information (MCSections, MCSymbols, etc.) and the two AsmPrinter passes interfere with each other. > > The only way I've been able to get this to work is to create an entirely separate PassManager, and use addPassesToEmitFile() on it, which will redo the entire CodeGen process again unnecessarily. > Does anyone have any ideas/pointers on how I might do this efficiently? This is only for a debugging aid, but I'd like to not have to compile everything twice when it's enabled. > > Thanks > Craig > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Craig Smith
2014-Jun-24 21:24 UTC
[LLVMdev] Any way get debug output of generated assembly from MCJIT without completely redoing CodeGen?
No, I just mean human-readable text assembly (aka .s file contents equivalent to what is JIT compiled into memory). I don't actually have any need for 'actual' debug info, since it doesn't exist in the original IR. Sorry my use of 'debug' was confusing. On Jun 24, 2014, at 3:57 PM, Eric Christopher <echristo at gmail.com> wrote:> By "debug output" you mean actual debug info or something else? > > If it's the actual debug info then the answer is no. > > -eric > > On Tue, Jun 24, 2014 at 1:33 PM, Craig Smith <craig at ni.com> wrote: >> >> Hello all, >> >> I'm trying to hack MCJIT::emitObject to optionally output the corresponding text assembly associated with the object code being emitted (if a debug flag is set in the app/dev environment which is hosting LLVM). >> I attempted to do this by adding another AsmPrinter pass to the PassManager, but this runs into all sorts of problems because there's only once MCContext and one MachneModuleInfo pass maintaining various state information (MCSections, MCSymbols, etc.) and the two AsmPrinter passes interfere with each other. >> >> The only way I've been able to get this to work is to create an entirely separate PassManager, and use addPassesToEmitFile() on it, which will redo the entire CodeGen process again unnecessarily. >> Does anyone have any ideas/pointers on how I might do this efficiently? This is only for a debugging aid, but I'd like to not have to compile everything twice when it's enabled. >> >> Thanks >> Craig >> >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Kevin Modzelewski
2014-Jun-24 22:03 UTC
[LLVMdev] Any way get debug output of generated assembly from MCJIT without completely redoing CodeGen?
We do this in Pyston using a JITEventListener that just disassembles the output; it's "it works let's move on"-quality: https://github.com/dropbox/pyston/blob/master/src/codegen/dis.cpp I'm not sure how efficient the disassembling is, but at least the process is pretty self-contained. On Tue, Jun 24, 2014 at 1:33 PM, Craig Smith <craig at ni.com> wrote:> > Hello all, > > I'm trying to hack MCJIT::emitObject to optionally output the > corresponding text assembly associated with the object code being emitted > (if a debug flag is set in the app/dev environment which is hosting LLVM). > I attempted to do this by adding another AsmPrinter pass to the > PassManager, but this runs into all sorts of problems because there's only > once MCContext and one MachneModuleInfo pass maintaining various state > information (MCSections, MCSymbols, etc.) and the two AsmPrinter passes > interfere with each other. > > The only way I've been able to get this to work is to create an entirely > separate PassManager, and use addPassesToEmitFile() on it, which will redo > the entire CodeGen process again unnecessarily. > Does anyone have any ideas/pointers on how I might do this efficiently? > This is only for a debugging aid, but I'd like to not have to compile > everything twice when it's enabled. > > Thanks > Craig > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140624/f3ebc681/attachment.html>
Eric Christopher
2014-Jun-24 23:03 UTC
[LLVMdev] Any way get debug output of generated assembly from MCJIT without completely redoing CodeGen?
Yeah, that's probably how I'd do it. Might be useful if you guys want to contribute that as a command line option Kevin. -eric On Tue, Jun 24, 2014 at 3:03 PM, Kevin Modzelewski <kmod at dropbox.com> wrote:> We do this in Pyston using a JITEventListener that just disassembles the > output; it's "it works let's move on"-quality: > https://github.com/dropbox/pyston/blob/master/src/codegen/dis.cpp > > I'm not sure how efficient the disassembling is, but at least the process is > pretty self-contained. > > > On Tue, Jun 24, 2014 at 1:33 PM, Craig Smith <craig at ni.com> wrote: >> >> >> Hello all, >> >> I'm trying to hack MCJIT::emitObject to optionally output the >> corresponding text assembly associated with the object code being emitted >> (if a debug flag is set in the app/dev environment which is hosting LLVM). >> I attempted to do this by adding another AsmPrinter pass to the >> PassManager, but this runs into all sorts of problems because there's only >> once MCContext and one MachneModuleInfo pass maintaining various state >> information (MCSections, MCSymbols, etc.) and the two AsmPrinter passes >> interfere with each other. >> >> The only way I've been able to get this to work is to create an entirely >> separate PassManager, and use addPassesToEmitFile() on it, which will redo >> the entire CodeGen process again unnecessarily. >> Does anyone have any ideas/pointers on how I might do this efficiently? >> This is only for a debugging aid, but I'd like to not have to compile >> everything twice when it's enabled. >> >> Thanks >> Craig >> >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Maybe Matching Threads
- [LLVMdev] Any way get debug output of generated assembly from MCJIT without completely redoing CodeGen?
- [LLVMdev] Function-at-a-time Processing
- Deleting function IR after codegen
- [LLVMdev] Static code generation - is it gone from LLVM 2.7?
- [LLVMdev] Static code generation - is it gone from LLVM 2.7?