Hi I know that LLVM provide some debug API for us to know the source code information. For example, every IR instruction's source line number and column number. However, are there any method to get a mapping from IR instruction to binary address directly. I don't want to use dwarf line mapping table as a bridge. I think the binary is generated by clang and llvm. I think there definitely is some information about the mapping relationship between LLVM IR and the target binary address. Do anyone has suggestions? Many Thanks Regards Muhui -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180612/691588c8/attachment.html>
In theory that’s not exactly possible/accurate. Due to various operations in the Backend like Instruction Legalization, one IR instruction might got emitted into multiple assembly instruction, for example Zhang> 在 2018年6月12日,22:30,Muhui Jiang via llvm-dev <llvm-dev at lists.llvm.org> 写道: > > Hi > > I know that LLVM provide some debug API for us to know the source code information. For example, every IR instruction's source line number and column number. > > However, are there any method to get a mapping from IR instruction to binary address directly. I don't want to use dwarf line mapping table as a bridge. I think the binary is generated by clang and llvm. I think there definitely is some information about the mapping relationship between LLVM IR and the target binary address. Do anyone has suggestions? Many Thanks > > Regards > Muhui > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
After the code is generated all you could really use would be debug info in the line table. There was for a time an LLVM pass ("DebugIR") for creating debug info/line table entries from LLVM textual IR source that'd give you the correspondence between the textual IR and the resulting machine code - but it's dead/removed - some folks might be trying to resurrect it somewhere, but I've not been keeping track. On Tue, Jun 12, 2018 at 7:30 AM Muhui Jiang via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hi > > I know that LLVM provide some debug API for us to know the source code > information. For example, every IR instruction's source line number and > column number. > > However, are there any method to get a mapping from IR instruction to > binary address directly. I don't want to use dwarf line mapping table as a > bridge. I think the binary is generated by clang and llvm. I think there > definitely is some information about the mapping relationship between LLVM > IR and the target binary address. Do anyone has suggestions? Many Thanks > > Regards > Muhui > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180612/a53abf08/attachment.html>
Hi However, frontend may also do various operations on the source code and one line number and column number could map to more than one binary address. Why LLVM IR cannot? Regrads Muhui 2018-06-12 23:18 GMT+08:00 mayuyu.io <admin at mayuyu.io>:> In theory that’s not exactly possible/accurate. Due to various operations > in the Backend like Instruction Legalization, one IR instruction might got > emitted into multiple assembly instruction, for example > > Zhang > > > 在 2018年6月12日,22:30,Muhui Jiang via llvm-dev <llvm-dev at lists.llvm.org> > 写道: > > > > Hi > > > > I know that LLVM provide some debug API for us to know the source code > information. For example, every IR instruction's source line number and > column number. > > > > However, are there any method to get a mapping from IR instruction to > binary address directly. I don't want to use dwarf line mapping table as a > bridge. I think the binary is generated by clang and llvm. I think there > definitely is some information about the mapping relationship between LLVM > IR and the target binary address. Do anyone has suggestions? Many Thanks > > > > Regards > > Muhui > > _______________________________________________ > > LLVM Developers mailing list > > llvm-dev at lists.llvm.org > > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180613/76eb7cb6/attachment.html>
Hi If I understand right. You mean LLVM ever has the "DebugIR" pass that can be used to map from textual IR to binary code but it is removed later. Right? If so , I would try to search the related information and thank you very much Regards Muhui 2018-06-13 4:27 GMT+08:00 David Blaikie <dblaikie at gmail.com>:> After the code is generated all you could really use would be debug info > in the line table. There was for a time an LLVM pass ("DebugIR") for > creating debug info/line table entries from LLVM textual IR source that'd > give you the correspondence between the textual IR and the resulting > machine code - but it's dead/removed - some folks might be trying to > resurrect it somewhere, but I've not been keeping track. > > On Tue, Jun 12, 2018 at 7:30 AM Muhui Jiang via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > >> Hi >> >> I know that LLVM provide some debug API for us to know the source code >> information. For example, every IR instruction's source line number and >> column number. >> >> However, are there any method to get a mapping from IR instruction to >> binary address directly. I don't want to use dwarf line mapping table as a >> bridge. I think the binary is generated by clang and llvm. I think there >> definitely is some information about the mapping relationship between LLVM >> IR and the target binary address. Do anyone has suggestions? Many Thanks >> >> Regards >> Muhui >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180613/a53fdf97/attachment.html>