diff options
| author | Rui Ueyama <ruiu@google.com> | 2016-02-25 18:56:01 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2016-02-25 18:56:01 +0000 |
| commit | 10bd2830411348f10210167258e954823339d344 (patch) | |
| tree | 8b54a13a7675a6c25832b769551a18d992ebf039 | |
| parent | c518d9b6ecc5c07022f4f69ac62e67e87211d12e (diff) | |
| download | bcm5719-llvm-10bd2830411348f10210167258e954823339d344.tar.gz bcm5719-llvm-10bd2830411348f10210167258e954823339d344.zip | |
ELF: Define log() to print out message if --verbose is given.
llvm-svn: 261919
| -rw-r--r-- | lld/ELF/Driver.cpp | 3 | ||||
| -rw-r--r-- | lld/ELF/Error.cpp | 6 | ||||
| -rw-r--r-- | lld/ELF/Error.h | 1 | ||||
| -rw-r--r-- | lld/ELF/ICF.cpp | 9 |
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); } } |

