From: Rui Ueyama Date: Thu, 25 Feb 2016 18:56:01 +0000 (+0000) Subject: ELF: Define log() to print out message if --verbose is given. X-Git-Tag: llvmorg-3.9.0-rc1~13214 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=10bd2830411348f10210167258e954823339d344;p=platform%2Fupstream%2Fllvm.git ELF: Define log() to print out message if --verbose is given. llvm-svn: 261919 --- diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 6b7ff3d..daef69f 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -89,8 +89,7 @@ static std::vector 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 4a5b8af..2f78108 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 55782b1..941190e 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 599d946..3ac37dc 100644 --- a/lld/ELF/ICF.cpp +++ b/lld/ELF/ICF.cpp @@ -349,8 +349,7 @@ template void ICF::run(SymbolTable *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 void ICF::run(SymbolTable *Symtab) { }); if (I == Bound) continue; - if (Config->Verbose) - llvm::outs() << "Selected " << Head->getSectionName() << "\n"; + log("Selected " + Head->getSectionName()); while (I != Bound) { InputSection *S = *I++; - if (Config->Verbose) - llvm::outs() << " Removed " << S->getSectionName() << "\n"; + log(" Removed " + S->getSectionName()); Head->replace(S); } }