perf tool support in MCJIT

I believe the perf tool cannot profile/analyze the JITed code in MCJIT model.

Can you please confirm this ? I was working on a patch to fix this.

Another question, is the there any support to map the llvm IR with x86 generated assembly ? so its easier to analyze the code generator.

I think you can profile code generated with MCJIT using either oprofile or Intel® VTune™ Amplifier XE, but you need to do a special build of LLVM to enable it. If you want to enable another performance tool, you can look at the code in lib/ExecutionEngine/OProfileJIT or lib/ExecutionEngine/IntelJITEvents to get an idea of how to do it. The IntelJITEvents implementation is a bit more complete, in that it makes use of generated DWARF information if it is available.

Speaking of DWARF information, Daniel Malea wrote a pass called DebugIR that if I recall correctly writes an IR file to disc and associates debug information with it as if that were the source file. You should be able to make that work with any DWARF-based tool to analyze the generated code.

-Andy

FWIW, Mesa3D has some LLVM <-> linux perf integration (and disassembly output too). This responsibility can and probably should be moved upstream to LLVM though.

For more information see:
  http://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp#n411
  http://cgit.freedesktop.org/mesa/mesa/tree/bin/perf-annotate-jit

Jose

Hi Jose,

with the MCJIT model, the size of the functions can be pre-determined, so there wouldn’t be a need to call the slower disassemble subroutine. I will try writing a simpler patch and submit it and perhaps it can be up streamed.

Thanks
sathvik

Hi Andrew,

Thanks for the pointer. I have tried the OProfileJIT agent in LLVM and it works fine. Its good to know that the VTune agent has been fixed to work with MCJIT. Do you have any pointers on how to generate the DWARF based output in LLVM which VTune would be able to use.

Thanks
-sathvik

That’s a good question. There’s a TargetOption named JITEmitDebugInfo but I’m not sure it actually does anything.

If you are starting with a bitcode file, you can get the debug information embedded in the bitcode using the usual command line options. (See for example, http://llvm.org/docs/DebuggingJITedCode.html).

In general, if the code generation options are set to generate debug information that information will find its way into DWARF format with MCJIT.

If you want the debug information mapped to the IR, there’s code in the lli tool that demonstrates how to do that (using lli’s ‘debug-ir’ command line option).

-Andy