Access to dynamic execution information.

Hi
Does LLVM dynamically run the program to obtain profiling information like branch weight? if so, can we access the information regarding this run like the number of instructions that have been executed dynamically between two specific points of the program?

Thanks

Hi,

depending on your specific use case you could have a look at the Sulong project (https://github.com/graalvm/sulong/). Sulong can execute LLVM IR programs and gathers profiling information during the program’s execution. For example, Sulong profiles the frequency of successor blocks in the interpreter, to then communicate it to the dynamic compiler for better optimization [1]. Similarly, you could implement a node that counts the number of executed instructions between two points in the program and instantiate it in the parser [2].

  • Manuel

[1] https://github.com/graalvm/sulong/blob/master/projects/com.oracle.truffle.llvm.nodes.impl/src/com/oracle/truffle/llvm/nodes/impl/base/LLVMBasicBlockNode.java
[2] https://github.com/graalvm/sulong/blob/master/projects/com.oracle.truffle.llvm.parser.impl/src/com/oracle/truffle/llvm/parser/impl/LLVMVisitor.java

Hi
Does LLVM dynamically run the program to obtain profiling information like branch weight?

No, the profile information is either collected via instrumentation of the program or via external sampling profilers. It is then read back into the IR by the frontend or an optimization pass.

if so, can we access the information regarding this run like the number of instructions that have been executed dynamically between two specific points of the program?

If Manuel Rigger’s suggestion doesn’t work, maybe try Valgrind which can get these kinds of instruction counts?

Thank you for your reply.