Skip to content

Commit 2ab9492

Browse files
[llc][NPM] Use buffer_ostream support for non-seekable streams (#168842)
NPM was missing buffering for non-seekable output streams (stdout, pipes), causing assertion failures when generating object files with `-o -`. Use buffer_ostream to provide seekable buffering, matching legacy PM behavior. Co-authored-by: vikhegde <[email protected]>
1 parent 3d3307e commit 2ab9492

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

llvm/tools/llc/NewPMDriver.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ int llvm::compileModuleWithNewPM(
101101

102102
raw_pwrite_stream *OS = &Out->os();
103103

104+
std::unique_ptr<buffer_ostream> BOS;
105+
if (codegen::getFileType() != CodeGenFileType::AssemblyFile &&
106+
!Out->os().supportsSeeking()) {
107+
BOS = std::make_unique<buffer_ostream>(Out->os());
108+
OS = BOS.get();
109+
}
110+
104111
// Fetch options from TargetPassConfig
105112
CGPassBuilderOption Opt = getCGPassBuilderOption();
106113
Opt.DisableVerify = VK != VerifierKind::InputOutput;

0 commit comments

Comments
 (0)