[cfe-users] Get Source Location details from IR code (Function Pass)

Bella V via cfe-users cfe-users at lists.llvm.org
Fri Jan 15 19:17:02 PST 2021


Thank you. Also Is there a pragmatically way to access the metadata info for
local variables within the llvm.dbg.declare.
( llvm::Value does not have local variables).

On Tue, Jan 12, 2021 at 1:55 PM David Blaikie <dblaikie at gmail.com> wrote:

> You'd have to get IR from somewhere that has attached debug info - such as
> clang -g
>
> On Tue, Jan 12, 2021 at 1:22 PM Bella V <bellavistaghome at gmail.com> wrote:
>
>> Do we have to initially attach some metadata to the Value? Because in
>> function pass, when I do F.getAllMetadata(MDs), i do not see any metadata
>> appending to MDS.
>> F.hasMetadata() also returns false. What would be the way to get debugLoc
>> in these scenario?
>>
>> Thanks and Regards.
>>
>> On Mon, Jan 11, 2021 at 6:31 PM David Blaikie <dblaikie at gmail.com> wrote:
>>
>>>
>>>
>>> On Mon, Jan 11, 2021 at 4:33 PM Ayush Mittal via cfe-users <
>>> cfe-users at lists.llvm.org> wrote:
>>>
>>>> Hello Cfe Users,
>>>>
>>>> Could you please point to an effective way to get Source Location
>>>> details from an IR code.
>>>> From the documentation, I think this could be a way:
>>>> Function Pass-> LLVM Value-> MDN->DILocation-> Source Location.
>>>>
>>>
>>> Yep, that's about it (I mean, you can do it in a pass, or not - but
>>> yes, find an llvm::Value and get the debugLoc from that)
>>>
>>>
>>>> Please include any example if the above approach is correct too.
>>>>
>>>> Thanks and Regards.
>>>> _______________________________________________
>>>> cfe-users mailing list
>>>> cfe-users at lists.llvm.org
>>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
>>>>
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20210115/a3d74f5f/attachment.html>


More information about the cfe-users mailing list