Update mmu_get... and mmu_set... by mhightower83 · Pull Request #8290 · esp8266/Arduino (original) (raw)
These changes are needed to address bugs that can emerge with the improved optimization from the GCC 10.3 compiler.
Updated performance inline functions mmu_get_uint8()
, ... and mmu_set_uint8()
, ... to comply with strict-aliasing rules.
Without this change, stale data may be referenced. This issue was revealed in discussions on #8261 (comment)
Changes to avoid over-optimization of 32-bit wide transfers from IRAM, turning into 8-bit or 16-bit transfers by the new GCC 10.3 compiler. This has been a reoccurring/tricky problem for me with the new compiler.
So far referencing the 32-bit value loaded by way of an Extended ASM R/W output register has stopped the compiler from optimizing down to an 8-bit or 16-bit transfer.
Example:
uint32_t val; __builtin_memcpy(&val, v32, sizeof(uint32_t)); asm volatile ("" :"+r"(val)); // inject 32-bit dependency ...
Updated example irammem.ino
- do a simple test of compliance to strict-aliasing rules
- For
mmu_get_uint8()
, added tests to evaluate if 32-bit wide transfers were converted to an 8-bit transfer.
Edited: Added missing references and clarifications.