[llvm] 0308975 - [Support] Don't tie errs() to outs() by default
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 11 15:20:08 PDT 2020
Author: Fangrui Song
Date: 2020-06-11T15:19:56-07:00
New Revision: 030897523d43e3296f69d25a71a140d9e5793c6a
URL: https://github.com/llvm/llvm-project/commit/030897523d43e3296f69d25a71a140d9e5793c6a
DIFF: https://github.com/llvm/llvm-project/commit/030897523d43e3296f69d25a71a140d9e5793c6a.diff
LOG: [Support] Don't tie errs() to outs() by default
This reverts part of D81156.
Accessing errs() concurrently was safe before and racy after D81156.
(`errs() << 'a'` is always racy)
Accessing outs() and errs() concurrently was safe before and racy after D81156.
Don't tie errs() to outs() by default to fix the fallout.
llvm-dwarfdump is single-threaded and opting in the tie behavior is safe.
Added:
Modified:
llvm/lib/Support/raw_ostream.cpp
llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
index c06ea55afcfd..f2d78d773239 100644
--- a/llvm/lib/Support/raw_ostream.cpp
+++ b/llvm/lib/Support/raw_ostream.cpp
@@ -878,7 +878,6 @@ raw_fd_ostream &llvm::outs() {
raw_fd_ostream &llvm::errs() {
// Set standard error to be unbuffered and tied to outs() by default.
static raw_fd_ostream S(STDERR_FILENO, false, true);
- S.tie(&outs());
return S;
}
diff --git a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
index d9e348e92282..47e426b2561b 100644
--- a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
+++ b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
@@ -606,6 +606,10 @@ static std::vector<std::string> expandBundle(const std::string &InputPath) {
int main(int argc, char **argv) {
InitLLVM X(argc, argv);
+ // Flush outs() when printing to errs(). This avoids interleaving output
+ // between the two.
+ errs().tie(&outs());
+
llvm::InitializeAllTargetInfos();
llvm::InitializeAllTargetMCs();
More information about the llvm-commits
mailing list