[LLVMdev] Get the loop trip count variable
Eli Friedman
eli.friedman at gmail.com
Mon Apr 5 13:51:31 PDT 2010
On Mon, Apr 5, 2010 at 1:19 PM, Zheng Wang <jason.wangz at gmail.com> wrote:
> Hello,
>
> I am wondering whether I can get the variable name of loop trip count in LLVM?
>
> For example,
>
> int NUM;
>
> NUM=atoi(argv[i]);
>
> 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.
-Eli
More information about the llvm-dev
mailing list