News for hackers. Stuff that matters.
Re:Ifs and &&s and Plan 9's Source Code by DannyBee on Friday May 24, 2013 @05:53PM (#5765372)
Both line and column information are completely carried through the process, and put into debug info, these days.

It's not hacky, it's actually completely well structured. Even debugging info for C/C++ macros is there and done properly.

None of this is new. DWARF2 (or 3 or 4), the standard debugging format for all non-MS compilers, has been able to do this well since 1993.

Re:Ifs and &&s and Plan 9's Source Code by rayiner on Friday May 24, 2013 @06:14PM (#5765469)
It's hacky in the sense that it's somewhat ad-hoc the manner in which line/column information makes it through from the source text, through the intermediate representation and optimizations, into the generated code and debug information.

In Clang/LLVM, for example, nodes are annotated with debug information using LLVM's metadata system. However, it is strictly optional for any given transformation to preserve the metadata on IR nodes. So what makes it through after optimizations is kind of a "best effort" affair.

Re:Ifs and &&s and Plan 9's Source Code by DannyBee on Friday May 24, 2013 @06:52PM (#5765654)
But this is not ad-hoc at all. This is how it is deliberately designed so it degrades gracefully depending on what optimizations you choose.

Not all compilers even really degrade. GCC does post-hoc variable tracking (and thus is mostly unaffected by optimization except when values are optiized out completely). For declarations and statements, the info is always on the declaration, so it won't be lost.

Both compiler guarantee that at -O0, all debug info will be kept.