diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2017-11-21 10:41:45 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2017-11-30 13:18:39 +0000 |
commit | c6497e3eac1ac81497f02b40ea7f140a997b4f29 (patch) | |
tree | aa969b1bd80c66e790413e59195eb8b24370cf18 /src/corelib/global/qlogging.h | |
parent | 7967c40303604bf1a02fe987ffc667e4e55d9af2 (diff) |
Mark some functions as cold
Add Q_DECL_COLD_FUNCTION (__attribute__((cold))) to tell the compiler
that the following functions are not usually executed in normal programs:
- qWarning/qCritical/qFatal
- qTerminate
- assertion failure
- qBadAlloc
The effect of the attribute is that
1. These functions get put into their own section, .text.unlikely,
and will be optimized for size, not speed.
2. Conditions that lead to one of these functions are automatically
marked as unlikely (something we have done manually in the past)
3. (anecdotal) the compiler is less likely to inline these functions
Text size effect of this change over all of QtBase: ~27KiB text size
saved, of which 11KiB in QtCore alone.
Change-Id: If308d4a4b9ff8f7934316c54b161a78ebe3f4205
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/global/qlogging.h')
-rw-r--r-- | src/corelib/global/qlogging.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/corelib/global/qlogging.h b/src/corelib/global/qlogging.h index 0c8d7dab38..16e01183bd 100644 --- a/src/corelib/global/qlogging.h +++ b/src/corelib/global/qlogging.h @@ -97,7 +97,9 @@ public: void noDebug(const char *, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3) {} void info(const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); + Q_DECL_COLD_FUNCTION void warning(const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); + Q_DECL_COLD_FUNCTION void critical(const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); typedef const QLoggingCategory &(*CategoryFunction)(); @@ -106,14 +108,19 @@ public: void debug(CategoryFunction catFunc, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4); void info(const QLoggingCategory &cat, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4); void info(CategoryFunction catFunc, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4); + Q_DECL_COLD_FUNCTION void warning(const QLoggingCategory &cat, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4); + Q_DECL_COLD_FUNCTION void warning(CategoryFunction catFunc, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4); + Q_DECL_COLD_FUNCTION void critical(const QLoggingCategory &cat, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4); + Q_DECL_COLD_FUNCTION void critical(CategoryFunction catFunc, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4); #ifndef Q_CC_MSVC Q_NORETURN #endif + Q_DECL_COLD_FUNCTION void fatal(const char *msg, ...) const Q_DECL_NOTHROW Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); #ifndef QT_NO_DEBUG_STREAM @@ -179,8 +186,8 @@ private: Q_CORE_EXPORT void qt_message_output(QtMsgType, const QMessageLogContext &context, const QString &message); -Q_CORE_EXPORT void qErrnoWarning(int code, const char *msg, ...); -Q_CORE_EXPORT void qErrnoWarning(const char *msg, ...); +Q_CORE_EXPORT Q_DECL_COLD_FUNCTION void qErrnoWarning(int code, const char *msg, ...); +Q_CORE_EXPORT Q_DECL_COLD_FUNCTION void qErrnoWarning(const char *msg, ...); #if QT_DEPRECATED_SINCE(5, 0)// deprecated. Use qInstallMessageHandler instead! typedef void (*QtMsgHandler)(QtMsgType, const char *); |