RDPMC inst use in llvm

I want to measure the performance of a JITed code snippet on MCJIT.
so I was planning to inject the RDPMC inst for the code generated through a llvm IR builder.

Is there a patch available ? If there’s a better way to do it please chime in.


I assume the easier way to do this is to add an inline assembly call that uses the RDPMC instruction. I don’t think there’s an LLVM IR intrinsic function that does it. Regards, John Criswell

Hi John,

I don’t think its possible to add/insert an inline assembly into the LLVM IR unless the IR interface provides some kind of stream writer into which inline instructions can be written into.

I was thinking having an LLVM intrinsic function could be a first step towards introducing PMU tool support in LLVM with which you can generate code with built-in instrumentation. What do you think ?


The LLVM IR supports inline assembly instructions. See the Language Reference Manual and the doxygen information on the llvm::InlineAsm class. If you wanted to build a processor-independent tool to collect the information that RDPMC provides, then I think an intrinsic would be the way to go. However, that might be a greater goal than what you currently need. It certainly seems like a difficult issue to make them portable given how different PMCs are across different Intel processors. Regards, John Criswell