Stephen Thomas
2015-May-28 13:08 UTC
[LLVMdev] Easiest way to collect dynamic Instruction execution counts?
Hi, I'd like a simple and fast way to collect the number of times each Instruction was executed in a given run of the application. As far as I can tell, there are a number of approaches I can take: - Use PIN. This would require using DWARF debug info and Instruction debug info to attempt to map instructions in the binary to instructions in the bitcode; not 100% sure how accurate this will be. - Use llvm-prof. Two questions here. First, I've seen on Stack Overflow <https://stackoverflow.com/questions/14617067/collecting-llvm-edge-profiling-with-llvm-prof> an option to `opt` called `--insert-edge-profiling`. However, that option doesn't seem to be available in 3.6? Second, it appears that such profiling only records execution counts at the Function level, not at the individual Instruction level. Is that correct? - Write a new tool similar to AddressSanitizer. <http://clang.llvm.org/docs/AddressSanitizer.html> This may work, but seems like overkill. Is there an easier way to achieve my goal that I'm missing? Thanks, Steve -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150528/2848ac08/attachment.html>
Bruce Hoult
2015-May-28 13:34 UTC
[LLVMdev] Easiest way to collect dynamic Instruction execution counts?
That seems like a job for valgrind? Assuming you're on a supported platform, but these days that includes all the common Mac/Linux/Android platforms except ARM64. On Thu, May 28, 2015 at 4:08 PM, Stephen Thomas < stephen.warner.thomas at gmail.com> wrote:> Hi, > > I'd like a simple and fast way to collect the number of times each > Instruction was executed in a given run of the application. As far as I can > tell, there are a number of approaches I can take: > > - Use PIN. This would require using DWARF debug info and Instruction debug > info to attempt to map instructions in the binary to instructions in the > bitcode; not 100% sure how accurate this will be. > > - Use llvm-prof. Two questions here. First, I've seen on Stack Overflow > <https://urldefense.proofpoint.com/v2/url?u=https-3A__stackoverflow.com_questions_14617067_collecting-2Dllvm-2Dedge-2Dprofiling-2Dwith-2Dllvm-2Dprof&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=HtoNbGGO3zcoVy6n3_8lqn7ZXiNnqiQKim27ER3buUQ&s=kf8XiNx6628Vrx9TCVI4rrnisNDMVf8ZcuKA6V0udhE&e=> > an option to `opt` called `--insert-edge-profiling`. However, that option > doesn't seem to be available in 3.6? Second, it appears that such profiling > only records execution counts at the Function level, not at the individual > Instruction level. Is that correct? > > - Write a new tool similar to AddressSanitizer. > <https://urldefense.proofpoint.com/v2/url?u=http-3A__clang.llvm.org_docs_AddressSanitizer.html&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=HtoNbGGO3zcoVy6n3_8lqn7ZXiNnqiQKim27ER3buUQ&s=B48ymTvL2IOafrTkfbB7YJl2y6OdfQtG7_I7dfiuNPU&e=> This > may work, but seems like overkill. > > Is there an easier way to achieve my goal that I'm missing? > > Thanks, > Steve > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150528/7dfa2dc1/attachment.html>
Stephen Thomas
2015-May-28 14:18 UTC
[LLVMdev] Easiest way to collect dynamic Instruction execution counts?
Bruce, Can valgrind give me the execution counts for each Instruction in the LLVM bitcode? Thanks, Steve On Thu, May 28, 2015 at 9:34 AM, Bruce Hoult <bruce at hoult.org> wrote:> That seems like a job for valgrind? > > Assuming you're on a supported platform, but these days that includes all > the common Mac/Linux/Android platforms except ARM64. > > On Thu, May 28, 2015 at 4:08 PM, Stephen Thomas < > stephen.warner.thomas at gmail.com> wrote: > >> Hi, >> >> I'd like a simple and fast way to collect the number of times each >> Instruction was executed in a given run of the application. As far as I can >> tell, there are a number of approaches I can take: >> >> - Use PIN. This would require using DWARF debug info and Instruction >> debug info to attempt to map instructions in the binary to instructions in >> the bitcode; not 100% sure how accurate this will be. >> >> - Use llvm-prof. Two questions here. First, I've seen on Stack Overflow >> <https://urldefense.proofpoint.com/v2/url?u=https-3A__stackoverflow.com_questions_14617067_collecting-2Dllvm-2Dedge-2Dprofiling-2Dwith-2Dllvm-2Dprof&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=HtoNbGGO3zcoVy6n3_8lqn7ZXiNnqiQKim27ER3buUQ&s=kf8XiNx6628Vrx9TCVI4rrnisNDMVf8ZcuKA6V0udhE&e=> >> an option to `opt` called `--insert-edge-profiling`. However, that option >> doesn't seem to be available in 3.6? Second, it appears that such profiling >> only records execution counts at the Function level, not at the individual >> Instruction level. Is that correct? >> >> - Write a new tool similar to AddressSanitizer. >> <https://urldefense.proofpoint.com/v2/url?u=http-3A__clang.llvm.org_docs_AddressSanitizer.html&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=HtoNbGGO3zcoVy6n3_8lqn7ZXiNnqiQKim27ER3buUQ&s=B48ymTvL2IOafrTkfbB7YJl2y6OdfQtG7_I7dfiuNPU&e=> This >> may work, but seems like overkill. >> >> Is there an easier way to achieve my goal that I'm missing? >> >> Thanks, >> Steve >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> >> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150528/c32c588f/attachment.html>
John Criswell
2015-May-28 14:39 UTC
[LLVMdev] Easiest way to collect dynamic Instruction execution counts?
Dear Stephen, Kevin, one of my students, wrote an LLVM pass and run-time library that records and reports the number of dynamic LLVM instructions executed by a program. You can find the code at https://github.com/hxy9243/priv_analysis. The pass you want is in DynCount.cpp, and the code works with LLVM mainline. One thing that this pass does is to alter the dynamic counts slightly to account for additional branches that our other transformation adds before analysis but will remove before code generation, so you may need to adjust the code slightly. Regards, John Criswell On 5/28/15 8:08 AM, Stephen Thomas wrote:> Hi, > > I'd like a simple and fast way to collect the number of times each > Instruction was executed in a given run of the application. As far as > I can tell, there are a number of approaches I can take: > > - Use PIN. This would require using DWARF debug info and Instruction > debug info to attempt to map instructions in the binary to > instructions in the bitcode; not 100% sure how accurate this will be. > > - Use llvm-prof. Two questions here. First, I've seen on Stack > Overflow > <https://urldefense.proofpoint.com/v2/url?u=https-3A__stackoverflow.com_questions_14617067_collecting-2Dllvm-2Dedge-2Dprofiling-2Dwith-2Dllvm-2Dprof&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=HtoNbGGO3zcoVy6n3_8lqn7ZXiNnqiQKim27ER3buUQ&s=kf8XiNx6628Vrx9TCVI4rrnisNDMVf8ZcuKA6V0udhE&e=> > an option to `opt` called `--insert-edge-profiling`. However, that > option doesn't seem to be available in 3.6? Second, it appears that > such profiling only records execution counts at the Function level, > not at the individual Instruction level. Is that correct? > > - Write a new tool similar to AddressSanitizer. > <https://urldefense.proofpoint.com/v2/url?u=http-3A__clang.llvm.org_docs_AddressSanitizer.html&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=HtoNbGGO3zcoVy6n3_8lqn7ZXiNnqiQKim27ER3buUQ&s=B48ymTvL2IOafrTkfbB7YJl2y6OdfQtG7_I7dfiuNPU&e=> This > may work, but seems like overkill. > > Is there an easier way to achieve my goal that I'm missing? > > Thanks, > Steve > > > _______________________________________________ > 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/20150528/2a21f4c7/attachment.html>
Seemingly Similar Threads
- [LLVMdev] Easiest way to collect dynamic Instruction execution counts?
- [LLVMdev] Easiest way to collect dynamic Instruction execution counts?
- [LLVMdev] Clang 3.6.1 integration with MSVC++
- [LLVMdev] [RFC] Late May Update: Progress report on CMake build system's ability to replace autoconf
- [LLVMdev] [RFC] Late May Update: Progress report on CMake build system's ability to replace autoconf