[lld] 941f062 - [lld] Make error handling functions opaque
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 17 11:55:03 PST 2022
Author: Fangrui Song
Date: 2022-02-17T11:54:57-08:00
New Revision: 941f06282a3d304a96c1ea71b335be5fc91d8f7c
URL: https://github.com/llvm/llvm-project/commit/941f06282a3d304a96c1ea71b335be5fc91d8f7c
DIFF: https://github.com/llvm/llvm-project/commit/941f06282a3d304a96c1ea71b335be5fc91d8f7c.diff
LOG: [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
Added:
Modified:
lld/Common/ErrorHandler.cpp
lld/include/lld/Common/ErrorHandler.h
Removed:
################################################################################
diff --git a/lld/Common/ErrorHandler.cpp b/lld/Common/ErrorHandler.cpp
index e557e533dedc..4cacd82c9f35 100644
--- a/lld/Common/ErrorHandler.cpp
+++ b/lld/Common/ErrorHandler.cpp
@@ -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();
diff --git a/lld/include/lld/Common/ErrorHandler.h b/lld/include/lld/Common/ErrorHandler.h
index ce077290d60b..0ba4787e5888 100644
--- a/lld/include/lld/Common/ErrorHandler.h
+++ b/lld/include/lld/Common/ErrorHandler.h
@@ -143,17 +143,13 @@ class ErrorHandler {
/// 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);
More information about the llvm-commits
mailing list