Zhoulai
2015-Apr-27 16:45 UTC
[LLVMdev] How to dynamically profile LLVM IR, i.e., doing things along the program execution?
Hi, all I am wondering if it is possible to dynamically profile LLVM IR? For example, if I have a void foo(){ A a; a.goo(); //invoke a virtual function of class A } Assume we don't know which "goo()" of class "A" will be executed at run time. We may want to print the body of goo() as well as the bodies of the function called by goo() and etc., or do something along the execution trace. How can we do this kind of dynamic profiling? I recently learned some LLVM basics. It seems to me that the purpose of LLVM passes is static profiling, right? Thanks for your ideas. Zhoulai -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150427/2afc7261/attachment.html>
John Criswell
2015-May-01 12:41 UTC
[LLVMdev] How to dynamically profile LLVM IR, i.e., doing things along the program execution?
On 4/27/15 12:45 PM, Zhoulai wrote:> Hi, all > > I am wondering if it is possible to dynamically profile LLVM IR? For > example, if I have a > > void foo(){ > A a; > a.goo(); //invoke a virtual function of class A > } > Assume we don’t know which “goo()" of class “A” will be executed at > run time.The DSA CallTargets pass can get you a list of possible targets for an indirect function call.> We may want to print the body of goo() as well as the bodies of the > function called by goo() and etc., or do something along the execution > trace. > > How can we do this kind of dynamic profiling? I recently learned some > LLVM basics. It seems to me that the purpose of LLVM passes is static > profiling, right?I don't know of a pass that does this. However, it is trivial to write an LLVM pass that adds code before every indirect function call and prints out the address of the function that will be called. Using that information, you can build a dynamic call graph. Regards, John Criswell> > Thanks for your ideas. > > Zhoulai > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-- John Criswell Assistant Professor Department of Computer Science, University of Rochester http://www.cs.rochester.edu/u/criswell -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150501/94843195/attachment.html>