[LLVMdev] Get the loop trip count variable

Jeffrey Yasskin jyasskin at google.com
Tue Apr 6 08:49:48 PDT 2010


You'll have to look at the debug information, if it's still present.
See http://llvm.org/docs/SourceLevelDebugging.html. This is probably
not what you want to do though. The loop trip count may not even be a
simple variable. You might be able to transform the IR to record the
trip count somewhere, but the source is harder.

On Tue, Apr 6, 2010 at 3:15 AM, Zheng Wang <jason.wangz at gmail.com> wrote:
> Hi Eli,
>
> Could you tell me how to extract the variable name?
> The reason I want to do it at the IR level is because I have more
> information at this stage, such as, constant propagation and back
> edges.
>
> Cheers,
> Zheng
>
> On 5 April 2010 21:51, Eli Friedman <eli.friedman at gmail.com> wrote:
>> 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
>>
>
>
>
> --
> Best regards,
>
> WANG Zheng
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>




More information about the llvm-dev mailing list