[LLVMdev] Get the loop trip count variable
jason.wangz at gmail.com
Wed Apr 7 07:15:45 PDT 2010
Thanks! But I could not find -insert-optimal-edge-instrumenation pass
from "opt -help". Did you mean -insert-edge-profiling?
On 7 April 2010 12:29, Andreas Neustifter <astifter-llvm at gmx.at> wrote:
> On 04/05/2010 10:51 PM, Eli Friedman wrote:
>> On Mon, Apr 5, 2010 at 1:19 PM, Zheng Wang<jason.wangz at gmail.com> wrote:
>>> I am wondering whether I can get the variable name of loop trip count in
>>> For example,
>>> int NUM;
>>> for (int i=0; i<NUM; i++)
>>> How can I get the corresponding variable name for "NUM"? Then, I can
>>> instrument something in the source code to record the loop trip count
>>> for a given input data set.
>>> BasicBlock* b = L->getHeader();
>>> returns the basicblock of the loop header, but I don't know how to
>>> extract "NUM" from basicblock b.
>> If you need to instrument the source, you'd probably be better off
>> doing this with clang purely at the source level; by the time LLVM
>> loop analyzers can tell "NUM" is the trip count, the name is likely to
>> be lost due to optimization.
> You can also use the instrumentation pass
> (-insert-optimal-edge-instrumenation) to instrument all your code, this adds
> about 10% runtime overhead.
> Also with some tweaking the instrumentation pass could be talked into
> instrumenting only loop headers so that only the loop counts get recorded
> but for a code with a whole lot of loops this would be almost equivalent to
> do the optimal instrumentation. (For a loop with only one block in the body
> only one counter gets added anyway...)
More information about the llvm-dev