Is there any way to print assembly code of a function compiled by ExecutionEngine?

Hello!

I'm using LLVM's JIT in my project. Is there any way to view assembly
code of functions it generates without disassembling them from the
memory?

I'm not sure what you mean with "without disassembling them from the
memory". If one can't read the JIT functions from memory, then from where would we read it?

I wrote a function that can disassemble an arbitrary function using MC on

  http://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp

Is this what you're looking for?

If so, then perhaps this would be an useful thing to have in LLVM tree itself.

Jose

From: llvmdev-bounces@cs.uiuc.edu [mailto:llvmdev-bounces@cs.uiuc.edu] On Behalf Of lost
Subject: [LLVMdev] Is there any way to print assembly code of a function compiled by ExecutionEngine?

I'm using LLVM's JIT in my project. Is there any way to view assembly
code of functions it generates without disassembling them from the
memory?

We use the following:

    Context = getGlobalContext();
    m3log = new dt_ostream(sysLogger);
    fm3log = new formatted_raw_ostream(*m3log);
    pMod = new Module("label", Context);
    TD = new TargetData(pMod->getDataLayout());
    pMPasses = new PassManager();
    pMPasses->add(new TargetData(*TD));
    tmc->addPassesToEmitFile(*pMPasses, *fm3log, TargetMachine::CGFT_AssemblyFile);
    pMPasses->run(*pMod);

(Lots of other bits omitted from the above for simplicity.)

Reference:
http://llvm.org/docs/doxygen/html/classllvm_1_1LLVMTargetMachine.html#a5c437ac9b4d158e38ad4e826dac63914

- Chuck

THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.