[LLVMdev] Annotating output assembly with input C statements

Eli Bendersky eliben at google.com
Mon Apr 15 15:31:17 PDT 2013


On Mon, Apr 15, 2013 at 3:17 PM, Alireza Moshtaghi <
Alireza.Moshtaghi at synopsys.com> wrote:

> Hi,
> I'm trying to annotate the final assembly output of my llvm codegen with
> the corresponding input C statements.
> It would've been super easy if the source information were included in the
> IR debug info. But obviously they are not, and there are good reasons why
> not !
> So I'm bound to collecting all my information in the back-end from the
> existing debug pseudo instructions. As you know, the debug instructions
> only have file name and line number information. But without actually
> parsing the input file and collecting the C statement and function start
> and end line numbers in the file, it would be a non-trivial task to emit
> proper source line information in the output assembly. Obviously, it is not
> recommended to use clang objects in the backend either, so I was wondering
> if anyone in the llvm community has attempted this before. Currently, I'm
> planning on writing my own parser but if someone has better solutions,
> please let me know.
>


What, specifically, do you need a parser for? Specifying file+line pairs in
debug info is standard practice. The debugger should then have access to
the original C source file to show the code. Including input C code into
every binary with debug info would blow up its size considerably (C files
include a lot of code from include files...) and is unnecessary. Why is
displaying a line of C code corresponding to some file+line pair more than
just reading a specific line from a given file?

Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130415/ba08d732/attachment.html>


More information about the llvm-dev mailing list