summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/Driver.cpp3
-rw-r--r--lld/ELF/Error.cpp6
-rw-r--r--lld/ELF/Error.h1
-rw-r--r--lld/ELF/ICF.cpp9
4 files changed, 11 insertions, 8 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 6b7ff3d7f6e..daef69f6692 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -89,8 +89,7 @@ static std::vector<MemoryBufferRef> getArchiveMembers(MemoryBufferRef MB) {
// Newly created memory buffers are owned by this driver.
void LinkerDriver::addFile(StringRef Path) {
using namespace llvm::sys::fs;
- if (Config->Verbose)
- llvm::outs() << Path << "\n";
+ log(Path);
auto MBOrErr = MemoryBuffer::getFile(Path);
if (error(MBOrErr, "cannot open " + Path))
return;
diff --git a/lld/ELF/Error.cpp b/lld/ELF/Error.cpp
index 4a5b8af191f..2f78108010e 100644
--- a/lld/ELF/Error.cpp
+++ b/lld/ELF/Error.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "Error.h"
+#include "Config.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/raw_ostream.h"
@@ -18,6 +19,11 @@ namespace elf2 {
bool HasError;
llvm::raw_ostream *ErrorOS;
+void log(const Twine &Msg) {
+ if (Config->Verbose)
+ llvm::outs() << Msg << "\n";
+}
+
void warning(const Twine &Msg) { llvm::errs() << Msg << "\n"; }
void error(const Twine &Msg) {
diff --git a/lld/ELF/Error.h b/lld/ELF/Error.h
index 55782b1f608..941190e84d3 100644
--- a/lld/ELF/Error.h
+++ b/lld/ELF/Error.h
@@ -22,6 +22,7 @@ namespace elf2 {
extern bool HasError;
extern llvm::raw_ostream *ErrorOS;
+void log(const Twine &Msg);
void warning(const Twine &Msg);
void error(const Twine &Msg);
diff --git a/lld/ELF/ICF.cpp b/lld/ELF/ICF.cpp
index 599d9466385..3ac37dc93e1 100644
--- a/lld/ELF/ICF.cpp
+++ b/lld/ELF/ICF.cpp
@@ -349,8 +349,7 @@ template <class ELFT> void ICF<ELFT>::run(SymbolTable<ELFT> *Symtab) {
if (Id == NextId)
break;
}
- if (Config->Verbose)
- llvm::outs() << "ICF needed " << Cnt << " iterations.\n";
+ log("ICF needed " + Twine(Cnt) + " iterations.");
// Merge sections in the same group.
for (auto I = V.begin(), E = V.end(); I != E;) {
@@ -360,12 +359,10 @@ template <class ELFT> void ICF<ELFT>::run(SymbolTable<ELFT> *Symtab) {
});
if (I == Bound)
continue;
- if (Config->Verbose)
- llvm::outs() << "Selected " << Head->getSectionName() << "\n";
+ log("Selected " + Head->getSectionName());
while (I != Bound) {
InputSection<ELFT> *S = *I++;
- if (Config->Verbose)
- llvm::outs() << " Removed " << S->getSectionName() << "\n";
+ log(" Removed " + S->getSectionName());
Head->replace(S);
}
}
OpenPOWER on IntegriCloud