diff --git a/llvm/tools/llc/NewPMDriver.cpp b/llvm/tools/llc/NewPMDriver.cpp index fa82689ecf9ae..7ba17e5b82095 100644 --- a/llvm/tools/llc/NewPMDriver.cpp +++ b/llvm/tools/llc/NewPMDriver.cpp @@ -101,6 +101,13 @@ int llvm::compileModuleWithNewPM( raw_pwrite_stream *OS = &Out->os(); + std::unique_ptr BOS; + if (codegen::getFileType() != CodeGenFileType::AssemblyFile && + !Out->os().supportsSeeking()) { + BOS = std::make_unique(Out->os()); + OS = BOS.get(); + } + // Fetch options from TargetPassConfig CGPassBuilderOption Opt = getCGPassBuilderOption(); Opt.DisableVerify = VK != VerifierKind::InputOutput;