Variables that are modified also within ISRs must be marked volatile otherwise the compiler wrongly assumes they don't change. With LTO (link time optimization) the compiler optimizes calls across translation units and that wrong assumption produces real effects.
Co-locate millis() and micros() with code updating _millis. Also optimize micros() (from 2 to 0 divisions) and switch to uint32_t _millis as nothing uses the higher bits.
For marlin, compiling with -flto results in a 10% smaller binary and very likely faster too but unfortunately increases incremental compile times by ~7s.
Variables that are modified also within ISRs must be marked volatile otherwise the compiler wrongly assumes they don't change. With LTO (link time optimization) the compiler optimizes calls across translation units and that wrong assumption produces real effects.
Co-locate
millis()
andmicros()
with code updating_millis
. Also optimizemicros()
(from 2 to 0 divisions) and switch touint32_t _millis
as nothing uses the higher bits.For marlin, compiling with
-flto
results in a 10% smaller binary and very likely faster too but unfortunately increases incremental compile times by ~7s.