[LLVMdev] Trying to access the user defined variable name

Arvind Sudarsanam arvind.sudarsanam at aggiemail.usu.edu
Thu Jul 15 15:16:34 PDT 2010


Hi Devang,

I did try using DIVariable for accessing the MDNode, to no effect.

One point to note is, I try to access the debug information after
running the optimization pass "mem2reg". It seems "mem2reg" removes
all debug information. When I run -print-dbginfo pass before running
the mem2reg pass, I get a lot of info. But when I run the
-print-dbginfo pass after the mem2reg pass, I get nothing.

I look at the .ll file after mem2reg pass, it still has all the debug
information. Somehow, it is not being identified by the llvm APIs. I
am planning to write a program to parse the .ll file and access this
info myself. I was hoping that this program is already available.

Please let me know if I am missing anything or am incorrect about something.

Thanks a lot for your replies
Regards
Arvind

On Thu, Jul 15, 2010 at 3:39 PM, Devang Patel <devang.patel at gmail.com> wrote:
> On Thu, Jul 15, 2010 at 1:19 PM, Arvind Sudarsanam
> <arvind.sudarsanam at aggiemail.usu.edu> wrote:
>> Hi Devang,
>>
>> Thanks for your reply. You mentioned
>> " First parameter is the compiler generated temp. and 3rd parameter
>> provides info about the variable, including its name 'u'."ization pass >>
>> I did manage to get this far. But, I am finding it difficult to access
>> this info using LLVM APIs. The third parameter is of type "metadata".
>> So I was able to access it by casting it to MDNode. After that, I am
>> assuming that it gives me a handle to the metadata represented as
>> "!10"
>>
>> !10 = metadata !{i32 524544, metadata !9, metadata !"u", metadata !2,
>> i32 3, metadata !6} ; [DW_TAG_auto_variable ]
>>
>> From here, I am trying invain to access the variable name.
>> Is there something wrong in my approach? I feel that I have not
>> understood the method to access metadata in llvm.
>>
>
> Use DIVariable from DebugInfo.h to access fields of MDNode that is
> holding variable's info.
>
> -
> Devang
>



-- 
Arvind Sudarsanam
Utah State University
Phone: (435) 512-7769
E-mail: theonemorpheus at gmail.com
Web-site: http://cc.usu.edu/~asudarsanam



More information about the llvm-dev mailing list