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 >
sathvik
2014-Jun-25 01:09 UTC
[LLVMdev] Any way get debug output of generated assembly from MCJIT without completely redoing CodeGen?
Hi Craig, I am trying to JIT PHP code and this is a hack .. https://github.com/sathvikl/llvm/blob/master/lib/ExecutionEngine/OProfileJIT/OProfileJITEventListener.cpp It writes out file of JITed methods in /tmp using the OProfileJIT interface so if you register via the OProfile interface + JITEventListener *event_listener JITEventListener::createOProfileJITEventListener() + llvm_engine->RegisterJITEventListener(event_listener) and run oprofile, it will dump out the file with JITed methods into a file. If you use a disassembler, you can try libxed https://github.com/facebook/hhvm/blob/10b2a6a3a8075b676ea167ea49e6bba5b8cca68e/hphp/util/disasm.cpp shows how to use it. libxed is packaged here - https://software.intel.com/en-us/articles/pin-a-binary-instrumentation-tool-downloads I plan to write a cleaner interface for this so you can view it via perf but didn't get to it. sathvik On Tue, Jun 24, 2014 at 4:03 PM, Eric Christopher <echristo at gmail.com> wrote:> 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 > > > _______________________________________________ > 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/f8de2f6b/attachment.html>
Lang Hames
2014-Jun-25 01:57 UTC
[LLVMdev] Any way get debug output of generated assembly from MCJIT without completely redoing CodeGen?
This actually came up today in a related conversation I had with David Blaikie about RuntimeDyld testing. As Eric suggested, it would be nice to have a command line flag for something like this. I'd prefer to just dump objects to disk by default though, rather than disassemble them: Once they're dumped they can be disassembled and poked at via existing tools at leisure. Cheers, Lang. Sent from my iPad> On Jun 24, 2014, at 6:09 PM, sathvik <sathvikl at gmail.com> wrote: > > Hi Craig, > > I am trying to JIT PHP code and this is a hack .. > https://github.com/sathvikl/llvm/blob/master/lib/ExecutionEngine/OProfileJIT/OProfileJITEventListener.cpp > > It writes out file of JITed methods in /tmp using the OProfileJIT interface so if you register via the OProfile interface > + JITEventListener *event_listener = JITEventListener::createOProfileJITEventListener() > + llvm_engine->RegisterJITEventListener(event_listener) > > and run oprofile, it will dump out the file with JITed methods into a file. If you use a disassembler, you can try libxed > https://github.com/facebook/hhvm/blob/10b2a6a3a8075b676ea167ea49e6bba5b8cca68e/hphp/util/disasm.cpp > shows how to use it. > libxed is packaged here - > https://software.intel.com/en-us/articles/pin-a-binary-instrumentation-tool-downloads > > I plan to write a cleaner interface for this so you can view it via perf but didn't get to it. > > sathvik > > > > >> On Tue, Jun 24, 2014 at 4:03 PM, Eric Christopher <echristo at gmail.com> wrote: >> 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 >> > >> _______________________________________________ >> 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-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140624/65015522/attachment.html>