[llvm-dev] [ORC] Dump assembly from OrcJit
Lang Hames via llvm-dev
llvm-dev at lists.llvm.org
Fri Aug 16 13:06:52 PDT 2019
That is probably your best option for dumping textual assembly directly,
but unless you need local symbol names and enhanced disassembly notes there
is a better option: Dump object files from the JIT and disassemble them.
Dumping object files has two advantages over assembly: (1) it avoids
redundant codegen, so is much faster, and (2) the bits you're dumping are
*exactly* the bits flowing into the JIT linker: there is no chance of
getting misleading assembly due to a compiler misconfiguration or
persistent state bug.
One way to dump object files, which works for both LLJIT and custom stacks,
is to attach a dummy ObjectCache (see
and dump the ObjBuffers that are passed in to the cache to disk. You can
just return 'nullptr' from your dummy cache's getObject method, since you
are not really using it as a cache.
Alternatively, If you are writing a custom ORC stack there is a second
option: You can insert an ObjectTransformLayer between your IRCompileLayer
and ObjectLinkingLayer and use that to dump the buffers to disk.
I hope this helps!
On Thu, Aug 15, 2019 at 3:44 PM Caballero, Diego via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> Hi all,
> Is there a way to dump the generated assembly from OrcJit? I found this
> thread about MCJIT but nothing specific about OrcJit:
> I’m also aware of the alternative approach below, but I’m not sure if the
> output will be the same as the assembly generated by OrcJit. Probably not.
> std::string outStr;
> llvm::legacy::PassManager pm;
> llvm::raw_string_ostream stream(outStr);
> llvm::buffer_ostream pstream(stream);
> targetMachine->addPassesToEmitFile(pm, pstream, nullptr,
> llvm::errs() << "Assembly:\n" << outStr << "\n";
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev