Index: lib/Support/raw_ostream.cpp =================================================================== --- lib/Support/raw_ostream.cpp +++ lib/Support/raw_ostream.cpp @@ -490,8 +490,8 @@ static int getFD(StringRef Filename, std::error_code &EC, sys::fs::OpenFlags Flags) { // Handle "-" as stdout. Note that when we do this, we consider ourself - // the owner of stdout. This means that we can do things like close the - // file descriptor when we're done and set the "binary" flag globally. + // the owner of stdout. This means that we can do things like set the "binary" + // flag globally. if (Filename == "-") { EC = std::error_code(); // If user requested binary then put stdout into binary mode if @@ -523,6 +523,10 @@ return; } + // Do not close standard input/output streams. + if (FD <= STDERR_FILENO) + ShouldClose = false; + // Get the starting position. off_t loc = ::lseek(FD, 0, SEEK_CUR); #ifdef LLVM_ON_WIN32 Index: test/Other/empty.ll =================================================================== --- test/Other/empty.ll +++ test/Other/empty.ll @@ -0,0 +1,2 @@ +; RUN: /export/bpart/_users/abataev/development/llvm_commit3/build/bin/opt -analyze -time-passes -rewrite-map-file=- -stats -info-output-file=- %s 2>&1 | FileCheck %s +; CHECK: Total Execution Time