about summary refs log tree commit diff
path: root/src/rustllvm/PassWrapper.cpp
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2018-08-19 23:44:25 -0700
committerAlex Crichton <alex@alexcrichton.com>2018-08-19 23:46:32 -0700
commit9d54bf8df2677dd5f985838c5686efaa24a73b6c (patch)
tree6db4939f40969431412f1ec2b2e77d31e71d5bae /src/rustllvm/PassWrapper.cpp
parent3ac79c718475fd29b8be34dde667b683390c2aee (diff)
downloadrust-9d54bf8df2677dd5f985838c5686efaa24a73b6c.tar.gz
rust-9d54bf8df2677dd5f985838c5686efaa24a73b6c.zip
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.
Diffstat (limited to 'src/rustllvm/PassWrapper.cpp')
-rw-r--r--src/rustllvm/PassWrapper.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
index d9fbd494ab3..46825efeee2 100644
--- a/src/rustllvm/PassWrapper.cpp
+++ b/src/rustllvm/PassWrapper.cpp
@@ -556,7 +556,8 @@ LLVMRustWriteOutputFile(LLVMTargetMachineRef Target, LLVMPassManagerRef PMR,
   }
 
 #if LLVM_VERSION_GE(7, 0)
-  unwrap(Target)->addPassesToEmitFile(*PM, OS, nullptr, FileType, false);
+  buffer_ostream BOS(OS);
+  unwrap(Target)->addPassesToEmitFile(*PM, BOS, nullptr, FileType, false);
 #else
   unwrap(Target)->addPassesToEmitFile(*PM, OS, FileType, false);
 #endif