[llvm] Add option to dump IR to files instead of stderr (PR #66412)

Sebastian Neubauer via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 26 02:39:37 PDT 2023


================
@@ -720,9 +794,20 @@ void PrintIRInstrumentation::printBeforePass(StringRef PassID, Any IR) {
   if (!shouldPrintBeforePass(PassID))
     return;
 
-  dbgs() << "*** IR Dump Before " << PassID << " on " << getIRName(IR)
-         << " ***\n";
-  unwrapAndPrint(dbgs(), IR);
+  auto WriteIRToStream = [&](raw_ostream &Stream) {
+    Stream << "*** IR Dump Before " << PassID << " on " << getIRName(IR)
+           << " ***\n";
----------------
Flakebi wrote:

If we are writing to stderr, or even more if we are writing an .ll file, it is convenient to be able to pipe the file directly into opt again. So how about we add a leading `; ` to make this header line a comment?

(Same goes for printAfter and printAfterPassInvalidated.)

https://github.com/llvm/llvm-project/pull/66412


More information about the llvm-commits mailing list