Skip to content

Conversation

@ftynse
Copy link
Member

@ftynse ftynse commented Dec 31, 2024

Print operations are often used for debugging, immediately before the compiler aborts. In such cases, it is sometimes possible that the output isn't fully produced yet. Make sure it is by explicitly flushing the output.

Print operations are often used for debugging, immediately before the compiler
aborts. In such cases, it is sometimes possible that the output isn't fully
produced yet. Make sure it is by explicitly flushing the output.
@llvmbot
Copy link
Member

llvmbot commented Dec 31, 2024

@llvm/pr-subscribers-mlir

Author: Oleksandr "Alex" Zinenko (ftynse)

Changes

Print operations are often used for debugging, immediately before the compiler aborts. In such cases, it is sometimes possible that the output isn't fully produced yet. Make sure it is by explicitly flushing the output.


Full diff: https://github.com/llvm/llvm-project/pull/121382.diff

1 Files Affected:

  • (modified) mlir/lib/Dialect/Transform/IR/TransformOps.cpp (+2)
diff --git a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
index 106a7947350907..798853a75441a1 100644
--- a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
+++ b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
@@ -2840,6 +2840,7 @@ transform::PrintOp::apply(transform::TransformRewriter &rewriter,
     llvm::outs() << "top-level ]]]\n";
     state.getTopLevel()->print(llvm::outs(), printFlags);
     llvm::outs() << "\n";
+    llvm::outs().flush();
     return DiagnosedSilenceableFailure::success();
   }
 
@@ -2849,6 +2850,7 @@ transform::PrintOp::apply(transform::TransformRewriter &rewriter,
     llvm::outs() << "\n";
   }
 
+  llvm::outs().flush();
   return DiagnosedSilenceableFailure::success();
 }
 

@ftynse ftynse requested a review from rolfmorel January 3, 2025 18:29
@rolfmorel
Copy link
Contributor

Makes sense - LGTM!

@ftynse ftynse merged commit f6bfbc8 into llvm:main Jan 6, 2025
10 checks passed
@ftynse ftynse deleted the flush branch January 6, 2025 09:47
paulhuggett pushed a commit to paulhuggett/llvm-project that referenced this pull request Jan 7, 2025
Print operations are often used for debugging, immediately before the
compiler aborts. In such cases, it is sometimes possible that the output
isn't fully produced yet. Make sure it is by explicitly flushing the
output.
@nicolasvasilache
Copy link
Contributor

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants