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

Caldarale, Charles R Chuck.Caldarale at unisys.com
Thu Mar 1 05:38:15 PST 2012


> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at 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.





More information about the llvm-dev mailing list