[Mlir-commits] [mlir] b126010 - [mlir][AsmPrinter] Fix multi-threaded segfault by using explicit null stream per thread

River Riddle llvmlistbot at llvm.org
Thu Apr 15 12:27:12 PDT 2021


Author: River Riddle
Date: 2021-04-15T12:26:59-07:00
New Revision: b1260109fb4886256ee5858a026c1d3349a09eba

URL: https://github.com/llvm/llvm-project/commit/b1260109fb4886256ee5858a026c1d3349a09eba
DIFF: https://github.com/llvm/llvm-project/commit/b1260109fb4886256ee5858a026c1d3349a09eba.diff

LOG: [mlir][AsmPrinter] Fix multi-threaded segfault by using explicit null stream per thread

We were using llvm::nulls, but that isn't thread safe so we switch to giving each thread it's own null stream.

Differential Revision: https://reviews.llvm.org/D100578

Added: 
    

Modified: 
    mlir/lib/IR/AsmPrinter.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index 8a8f3be997597..66794b1dd8a17 100644
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -461,8 +461,9 @@ class DummyAliasOperationPrinter : private OpAsmPrinter {
     printOptionalAttrDict(attrs, elidedAttrs);
   }
 
-  /// Return 'nulls' as the output stream, this will ignore any data fed to it.
-  raw_ostream &getStream() const override { return llvm::nulls(); }
+  /// Return a null stream as the output stream, this will ignore any data fed
+  /// to it.
+  raw_ostream &getStream() const override { return os; }
 
   /// The following are hooks of `OpAsmPrinter` that are not necessary for
   /// determining potential aliases.
@@ -485,6 +486,9 @@ class DummyAliasOperationPrinter : private OpAsmPrinter {
 
   /// The initializer to use when identifying aliases.
   AliasInitializer &initializer;
+
+  /// A dummy output stream.
+  mutable llvm::raw_null_ostream os;
 };
 } // end anonymous namespace
 


        


More information about the Mlir-commits mailing list