diff options
authorMarc Mutz <>2015-01-22 11:47:45 +0100
committerMarc Mutz <>2015-03-25 10:18:44 +0000
commit2450a66001a3c0d1ad0d8f70bdac9fbc943bba11 (patch)
parentaab749487f620e27b7311c729de3922e7fd09049 (diff)
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 <>
1 files changed, 2 insertions, 0 deletions
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
static ParsedDate getDateFromJulianDay(qint64 julianDay)