From e789ea584f3a6ab81813de774fc7e124e153e1f8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 18 Oct 2023 10:43:22 +0200 Subject: [PATCH] QIODevice: mark checkWarnMessage() as Q_DECL_COLD_FUNCTION It's only called in exceptional circumstances, so the compiler should optimize it for size, not speed, and paths leading up to calls to this functions should be automatically marked as [[unlikely]]. Marking the function as cold accomplishes both. GCC 11 seems to have had this figured out by itself, possibly backtracking from the unconditional qWarning() in the first line of the function, but it did have a (very small) effect on Clang 15, so leave it in, if only as documentation. Pick-to: 6.5 6.2 Change-Id: Ie8e9049300825a3aae2f9678a2907ceea0b21d1c Reviewed-by: Fabian Kosmale (cherry picked from commit 546208f0ff23819d216cbb5bf0b5daded79b454e) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/io/qiodevice.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 81c2bc16959..723cc3e3232 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -45,6 +45,7 @@ static void debugBinaryString(const char *input, qint64 maxlen) #define Q_VOID +Q_DECL_COLD_FUNCTION static void checkWarnMessage(const QIODevice *device, const char *function, const char *what) { #ifndef QT_NO_WARNING_OUTPUT