title: execution frequency of header of a loop
body: <p>In a LLVM pass, I'd like to record the loop trip count of a loop. One part I did was inserting a function call before the terminator of the header block of each loop. I found that this method did not work well, because if a loop has n iterations, the header block will be executed n+1 times. This fact holds for "for" and "while" loop, but it does not hold for "do while" loop. I insert the function call to the second block of "for" and "while" loops, and to the first block of "do while" loops. This works only if I know a priori the kind the targeted loop, which is impossible through purely bitcode. My question is: is there a universal way (handling all kinds of loops) to insert a function call, which will be called exactly the same times as the number of iterations.</p>