[mlir] Bug fix. Stream must outlive the pass manager.
authorrdzhabarov <rdzhabarov@google.com>
Fri, 19 Nov 2021 21:43:17 +0000 (21:43 +0000)
committerrdzhabarov <rdzhabarov@google.com>
Fri, 19 Nov 2021 21:45:43 +0000 (21:45 +0000)
Bug fix. Stream must outlive the pass manager.

Reviewed By: Chia-hungDuan

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

mlir/lib/Dialect/GPU/Transforms/SerializeToBlob.cpp

index f8be171..6ae4662 100644 (file)
@@ -42,10 +42,10 @@ gpu::SerializeToBlobPass::translateToISA(llvm::Module &llvmModule,
   std::string targetISA;
   llvm::raw_string_ostream stream(targetISA);
 
-  llvm::legacy::PassManager codegenPasses;
-
   { // Drop pstream after this to prevent the ISA from being stuck buffering
     llvm::buffer_ostream pstream(stream);
+    llvm::legacy::PassManager codegenPasses;
+
     if (targetMachine.addPassesToEmitFile(codegenPasses, pstream, nullptr,
                                           llvm::CGFT_AssemblyFile))
       return llvm::None;