[llvm-commits] [llvm] r76117 - in /llvm/trunk: lib/CodeGen/AsmPrinter/AsmPrinter.cpp test/FrontendC++/2009-07-15-LineNumbers.cpp
Chris Lattner
clattner at apple.com
Fri Jul 17 09:24:41 PDT 2009
On Jul 16, 2009, at 3:24 PM, David Greene wrote:
> Author: greened
> Date: Thu Jul 16 17:24:20 2009
> New Revision: 76117
>
> Emit line numbers in asm comments when available.
Nice!
>
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Thu Jul 16
> 17:24:20 2009
> @@ -22,6 +22,7 @@
> #include "llvm/CodeGen/MachineModuleInfo.h"
> #include "llvm/CodeGen/DwarfWriter.h"
> #include "llvm/Analysis/DebugInfo.h"
> +#include "llvm/MC/MCInst.h"
> #include "llvm/Support/CommandLine.h"
> #include "llvm/Support/ErrorHandling.h"
> #include "llvm/Support/FormattedStream.h"
> @@ -1731,11 +1732,23 @@
> /// EmitComments - Pretty-print comments for instructions
> void AsmPrinter::EmitComments(const MachineInstr &MI) const
> {
> + if (!MI.getDebugLoc().isUnknown()) {
> + DebugLocTuple DLT = MF->getDebugLocTuple(MI.getDebugLoc());
> +
> + // Print source line info
> + O.PadToColumn(TAI->getCommentColumn(), 1);
> + O << TAI->getCommentString() << " SrcLine " << DLT.Line << ":"
> << DLT.Col;
> + }
> }
Please only emit comments if the "-asm-verbose" LLC flag is set.
Also, have you considered adding the filename (without leading path)
to the generated comments? It would be nice to see something like:
foo # Loc: x.c:2:42
Also, the column # should only print if non-zero. Thanks again for
working on this David!
-Chris
More information about the llvm-commits
mailing list