Proposal: Use filtered ICU data as the default in swift-foundation-icu

For this to be feasible, we need to have better outlining for literal data even in debug builds. Today, InlineArray suffers the same issue as Array where large arrays code-gen a huge one-time initialization function that is just a sequence of mov instructions to load each element individually into storage: Compiler Explorer

Compiling with -O will turn that into read-only data, and I suspect the various forms of @constInitialized that have been pitched would help out here as well, but it’s never been completely clear to me why the compiler doesn’t just do this by default for large static arrays that contain only literals regardless of build mode, like the C compiler does.

I’ve written more about this here but the discussion has never gained much traction (and I haven’t had the time to start digging into it myself, unfortunately).

4 Likes