summaryrefslogtreecommitdiff
path: root/tools/opt
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-05-27 19:47:36 +0000
committerDan Gohman <gohman@apple.com>2010-05-27 19:47:36 +0000
commit26a707493903729aab49e02a082a0e481003b760 (patch)
tree1648663d429b77cdf81c1da6ca60aa8a235df196 /tools/opt
parent57bd6431134d2fe7c8e9f8362b18e283d017b947 (diff)
downloadllvm-26a707493903729aab49e02a082a0e481003b760.tar.gz
llvm-26a707493903729aab49e02a082a0e481003b760.tar.bz2
llvm-26a707493903729aab49e02a082a0e481003b760.tar.xz
Avoid calling outs() and fouts() when the stream isn't really needed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104873 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/opt')
-rw-r--r--tools/opt/opt.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp
index 51b920f533..a29555ccf9 100644
--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -378,8 +378,12 @@ int main(int argc, char **argv) {
// Figure out what stream we are supposed to write to...
// FIXME: outs() is not binary!
- raw_ostream *Out = &outs(); // Default to printing to stdout...
- if (OutputFilename != "-") {
+ raw_ostream *Out = 0;
+ bool DeleteStream = true;
+ if (OutputFilename == "-") {
+ Out = &outs(); // Default to printing to stdout...
+ DeleteStream = false;
+ } else {
if (NoOutput || AnalyzeOnly) {
errs() << "WARNING: The -o (output filename) option is ignored when\n"
"the --disable-output or --analyze options are used.\n";
@@ -540,7 +544,7 @@ int main(int argc, char **argv) {
Passes.run(*M.get());
// Delete the raw_fd_ostream.
- if (Out != &outs())
+ if (DeleteStream)
delete Out;
return 0;
}