[llvm] b20a4e2 - [Support] Speedup llvm-dwarfdump 3.9x
Jan Kratochvil via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 26 01:30:11 PDT 2020
Author: Jan Kratochvil
Date: 2020-08-26T10:29:46+02:00
New Revision: b20a4e293c3b617d0890657b3c46edcc7410c8fd
URL: https://github.com/llvm/llvm-project/commit/b20a4e293c3b617d0890657b3c46edcc7410c8fd
DIFF: https://github.com/llvm/llvm-project/commit/b20a4e293c3b617d0890657b3c46edcc7410c8fd.diff
LOG: [Support] Speedup llvm-dwarfdump 3.9x
Currently `strace llvm-dwarfdump x.debug >/tmp/file`:
ioctl(1, TCGETS, 0x7ffd64d7f340) = -1 ENOTTY (Inappropriate ioctl for device)
write(1, " DW_AT_decl_line\t(89)\n"..., 4096) = 4096
ioctl(1, TCGETS, 0x7ffd64d7f400) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(1, TCGETS, 0x7ffd64d7f410) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(1, TCGETS, 0x7ffd64d7f400) = -1 ENOTTY (Inappropriate ioctl for device)
After this patch:
write(1, "0000000000001102 \"strlen\")\n "..., 4096) = 4096
write(1, "site\n DW_AT_low"..., 4096) = 4096
write(1, "d53)\n\n0x000e4d4d: DW_TAG_G"..., 4096) = 4096
The same speedup can be achieved by `--color=0` but that is not much convenient.
This implementation has been suggested by Joerg Sonnenberger.
Differential Revision: https://reviews.llvm.org/D86406
Added:
Modified:
llvm/include/llvm/Support/raw_ostream.h
llvm/lib/Support/raw_ostream.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h
index e9c710d0f38f..cae57430baff 100644
--- a/llvm/include/llvm/Support/raw_ostream.h
+++ b/llvm/include/llvm/Support/raw_ostream.h
@@ -412,6 +412,7 @@ class raw_fd_ostream : public raw_pwrite_stream {
int FD;
bool ShouldClose;
bool SupportsSeeking = false;
+ mutable Optional<bool> HasColors;
#ifdef _WIN32
/// True if this fd refers to a Windows console device. Mintty and other
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
index 86c48993957a..83050c8574d9 100644
--- a/llvm/lib/Support/raw_ostream.cpp
+++ b/llvm/lib/Support/raw_ostream.cpp
@@ -858,7 +858,9 @@ bool raw_fd_ostream::is_displayed() const {
}
bool raw_fd_ostream::has_colors() const {
- return sys::Process::FileDescriptorHasColors(FD);
+ if (!HasColors)
+ HasColors = sys::Process::FileDescriptorHasColors(FD);
+ return *HasColors;
}
Expected<sys::fs::FileLocker> raw_fd_ostream::lock() {
More information about the llvm-commits
mailing list