Skip to content

Commit 329dde5

Browse files
committed
Auto merge of #53524 - alexcrichton:buffer-out, r=eddyb
Buffer LLVM's object output stream In some profiling on OSX I saw the `write` syscall as quite high up on the profiling graph, which is definitely not good! It looks like we're setting the output stream of an object file as directly to a file descriptor which means that we run the risk of doing lots of little writes rather than a few large writes. This commit fixes this issue by adding a buffered stream on the output, causing the `write` syscall to disappear from the profiles on OSX.
2 parents 674ef66 + 9d54bf8 commit 329dde5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/rustllvm/PassWrapper.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,8 @@ LLVMRustWriteOutputFile(LLVMTargetMachineRef Target, LLVMPassManagerRef PMR,
556556
}
557557

558558
#if LLVM_VERSION_GE(7, 0)
559-
unwrap(Target)->addPassesToEmitFile(*PM, OS, nullptr, FileType, false);
559+
buffer_ostream BOS(OS);
560+
unwrap(Target)->addPassesToEmitFile(*PM, BOS, nullptr, FileType, false);
560561
#else
561562
unwrap(Target)->addPassesToEmitFile(*PM, OS, FileType, false);
562563
#endif

0 commit comments

Comments
 (0)