You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Audited against the finding in #3754 / #3486: fl::Singleton elision pays off only for objects with dynamic initialization (those register .init_array entries that pull in a ctor and resist --gc-sections). It does nothing for constant-initialized PODs — builds already pass -ffunction-sections -fdata-sections (ci/boards.py:795), so those are already dropped when unreferenced. For PODs the wrap is a net loss: storage grows by a T*, every access gains a null-check, and constant-initialization (race-free) is replaced by Singleton<T>::instance()'s hand-rolled if (!ptr), which bypasses the C++11 magic-static guard.
All 10 hits are constant-initialized PODs, and two of the four target paths are stale.
drivers/mcpwm/mcpwm_timer.cpp.hpp is actually drivers/gpio_isr_rx/mcpwm_timer.cpp.hpp; its single hit is L76 static const char* MCPWM_TIMER_TAG = "mcpwm_timer"; — a pointer to a string literal.
drivers/lcd_rgb/ is actually drivers/lcd_cam/, and it has zero hits.
Closing as not planned after checking every named driver against current master.
The proposed blanket migration does not produce the stated elision benefit:
LPUART's targeted pointer/bool/u32 fields are constant-initialized POD, several ISR-touched.
RMT5 already uses Singleton<Rmt5PeripheralESPImpl> for the real peripheral object. Its remaining file-scope hits are constant-initialized volatile diagnostic counters/GPIO state used from callback/ISR paths.
MCPWM has already been narrowed: MCPWM_TIMER_TAG is constexpr, and the actual McpwmState is already behind Singleton<McpwmState>.
LCD_CAM's remaining annotated s_vsync_cb_data is a zero-initialized three-pointer callback context whose address is registered with the IDF ISR callback. Moving it behind a lazy singleton plus a cached pointer would add storage and a lifetime invariant without eliminating a dynamic initializer.
Per-data sections plus linker GC already remove these POD sections when their driver TUs are unreachable. The cached-pointer workaround would add one pointer and indirection per driver precisely to preserve ISR safety around storage that is already constant-initialized and race-free. No measurable Blink data-footprint drop can follow from that transformation.
Parent #3481 is closed; the actually useful MCPWM constant/singleton cleanup has already landed. The remaining work should not be manufactured into four hardware PRs.
Activity
feat(lint): SingletonElisionChecker — land + drive to zero violations (…
zackees commentedon Jul 28, 2026
Audited against the finding in #3754 / #3486:
fl::Singletonelision pays off only for objects with dynamic initialization (those register.init_arrayentries that pull in a ctor and resist--gc-sections). It does nothing for constant-initialized PODs — builds already pass-ffunction-sections -fdata-sections(ci/boards.py:795), so those are already dropped when unreferenced. For PODs the wrap is a net loss: storage grows by aT*, every access gains a null-check, and constant-initialization (race-free) is replaced bySingleton<T>::instance()'s hand-rolledif (!ptr), which bypasses the C++11 magic-static guard.All 10 hits are constant-initialized PODs, and two of the four target paths are stale.
lpuart_driver.cpp.hpp:180-182,188-189— same shape as singleton: migrate flexio_driver state (Tier 2b) #3490.rmt5_peripheral_esp.cpp.hpp:140,265,268,271— fourvolatiledebug counters written from ISR context. Same ISR-vs-lazy-init objection as singleton: migrate flexio_driver state (Tier 2b) #3490, amplified.drivers/mcpwm/mcpwm_timer.cpp.hppis actuallydrivers/gpio_isr_rx/mcpwm_timer.cpp.hpp; its single hit is L76static const char* MCPWM_TIMER_TAG = "mcpwm_timer";— a pointer to a string literal.drivers/lcd_rgb/is actuallydrivers/lcd_cam/, and it has zero hits.Recommend closing as not-planned. See #3492.
singleton: sweep the safe <=2-hit files (Tier 1e)
singleton: sweep the safe <=2-hit files (Tier 1e) (#3756)
zackees commentedon Aug 20, 2026
Closing as not planned after checking every named driver against current master.
The proposed blanket migration does not produce the stated elision benefit:
Singleton<Rmt5PeripheralESPImpl>for the real peripheral object. Its remaining file-scope hits are constant-initialized volatile diagnostic counters/GPIO state used from callback/ISR paths.MCPWM_TIMER_TAGisconstexpr, and the actualMcpwmStateis already behindSingleton<McpwmState>.s_vsync_cb_datais a zero-initialized three-pointer callback context whose address is registered with the IDF ISR callback. Moving it behind a lazy singleton plus a cached pointer would add storage and a lifetime invariant without eliminating a dynamic initializer.Per-data sections plus linker GC already remove these POD sections when their driver TUs are unreachable. The cached-pointer workaround would add one pointer and indirection per driver precisely to preserve ISR safety around storage that is already constant-initialized and race-free. No measurable Blink data-footprint drop can follow from that transformation.
Parent #3481 is closed; the actually useful MCPWM constant/singleton cleanup has already landed. The remaining work should not be manufactured into four hardware PRs.