[lld] Make error handling functions opaque

The inline `lld::error` expands to two function calls `errorHandler` and `error`
where the latter is opaque. Move the functions to .cpp files to decrease code
size.

My x86-64 lld executable is 9KiB smaller.

Reviewed By: #lld-macho, thakis

Differential Revision: https://reviews.llvm.org/D120002
This commit is contained in:
Fangrui Song 2022-02-17 11:54:57 -08:00
parent a3beb34015
commit 941f06282a
2 changed files with 19 additions and 11 deletions

View File

@ -53,6 +53,18 @@ void ErrorHandler::flushStreams() {
ErrorHandler &lld::errorHandler() { return context().e; }
void lld::error(const Twine &msg) { errorHandler().error(msg); }
void lld::error(const Twine &msg, ErrorTag tag, ArrayRef<StringRef> args) {
errorHandler().error(msg, tag, args);
}
void lld::fatal(const Twine &msg) { errorHandler().fatal(msg); }
void lld::log(const Twine &msg) { errorHandler().log(msg); }
void lld::message(const Twine &msg, llvm::raw_ostream &s) {
errorHandler().message(msg, s);
}
void lld::warn(const Twine &msg) { errorHandler().warn(msg); }
uint64_t lld::errorCount() { return errorHandler().errorCount; }
raw_ostream &lld::outs() {
ErrorHandler &e = errorHandler();
return e.outs();

View File

@ -143,17 +143,13 @@ private:
/// Returns the default error handler.
ErrorHandler &errorHandler();
inline void error(const Twine &msg) { errorHandler().error(msg); }
inline void error(const Twine &msg, ErrorTag tag, ArrayRef<StringRef> args) {
errorHandler().error(msg, tag, args);
}
[[noreturn]] inline void fatal(const Twine &msg) { errorHandler().fatal(msg); }
inline void log(const Twine &msg) { errorHandler().log(msg); }
inline void message(const Twine &msg, llvm::raw_ostream &s = outs()) {
errorHandler().message(msg, s);
}
inline void warn(const Twine &msg) { errorHandler().warn(msg); }
inline uint64_t errorCount() { return errorHandler().errorCount; }
void error(const Twine &msg);
void error(const Twine &msg, ErrorTag tag, ArrayRef<StringRef> args);
[[noreturn]] void fatal(const Twine &msg);
void log(const Twine &msg);
void message(const Twine &msg, llvm::raw_ostream &s = outs());
void warn(const Twine &msg);
uint64_t errorCount();
[[noreturn]] void exitLld(int val);