[PATCH] D30897: [WIP] New AsmPrinterHandler that is able to interleave source code

Hal Finkel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 14 13:36:32 PDT 2017


hfinkel added inline comments.


================
Comment at: include/llvm/MC/MCTargetOptions.h:29
+    Alone,
+    WithDebug
+};
----------------
As I mentioned in the Clang review; this should be some kind of factored-out feature.


================
Comment at: lib/CodeGen/AsmPrinter/SourceInterleave.cpp:129
+
+    AP->OutStreamer->emitRawComment(OS.str(), false);
+  }
----------------
I'd like to see this at greater than line granularity when column information is available. We should be able to have something like this:

  // for (int i = 0; i < n; ++i)
  //         ^
  xor r1, r1, r1
  
  ...
  
  // for (int i = 0; i < n; ++i)
  //                         ^
  cmp r1, r22

Doing this well means figuring out beforehand whether there are instructions with different column values for a particular line. This is a bit more work, but I can say from my experience making llvm-opt-report, it is definitely worth it.

Also, I'd like to see the line numbers prepended to the line. Since the lines don't always appear in order, this is important. Same with file names, when we print a line in a different file from the previously-printed line, we should say so:

  // In foo/bar.c
  // int x = a + b;
  add r4, r5, r6



https://reviews.llvm.org/D30897





More information about the llvm-commits mailing list