From 2450a66001a3c0d1ad0d8f70bdac9fbc943bba11 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 22 Jan 2015 11:47:45 +0100 Subject: QDateTime: prevent aggressive inlining The function getDateFromJulianDay() is simple arithmetic, but still ~400 bytes in executable size. Yet GCC inlines this everywhere I looked, which makes some sense, as different users of the class only use parts of the return value and the optimizer has a field day removing all that dead code. However, that function has only one conditional, so presumably it executes at full pipeline speed and it doesn't matter that it calculates too much in some cases. More important is to use the I-cache more conservatively. That's what not inlining the function achieves. The function returns its result in registers and doesn't spill registers when called (at least on AMD64), so the effect on runtime should be negligible. Effects on Linux GCC 4.9 stripped release builds: text -1536B data +-0B relocs +-0 Change-Id: Ia16838102d29ad67ee5efdc8b7b0a26f2f921df1 Reviewed-by: Thiago Macieira --- src/corelib/tools/qdatetime.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 7d1ed9d2ba..a16cfef1b2 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -122,6 +122,8 @@ struct ParsedDate int year, month, day; }; +// prevent this function from being inlined into all 10 users +Q_NEVER_INLINE static ParsedDate getDateFromJulianDay(qint64 julianDay) { /* -- cgit v1.2.3