Skip to content

WIP: nir: Eliminate .data and .bss from nir_opt_algebraic

Adam Jackson requested to merge ajax/mesa:nir-opt-algebraic into master

This came out to something like -30k relocations, -1400k .data, and -300k .bss on my machine, ymmv. What's happening here is that the word static doesn't just mean please limit my scope to the containing block or CU, it also means allocate me at program startup. And for some reason gcc honors this promise even for a const variable whose address provably never leaves the scope of the compilation unit. So all those &foo indirections have to be resolved at (dynamic!) link time, and that all has to now live in writable (and thus per-process dirty) memory.

If you fold the tables into the function body and remove static, then that all becomes expressions the compiler is allowed to optimize, and boy howdy does it like to try to optimize this. On the machine I'm typing on (admittedly a 2.3GHz Haswell) nir_opt_algebraic.c takes about 14 minutes to compile now.


Putting this up for posterity and/or further investigation, and because I'm curious how badly CI chokes on it. When I posted this on IRC @jenatali tried it with MSVC and it was a complete loss, the 32-bit compiler would crash and the 64-bit one produced a much larger executable (I don't remember whether it was text or data, but since they're doing four-arch fat binaries text size is already a pain point). No idea what clang is going to make of it.

With luck, we can come up with something that optimizes well across compilers and doesn't take an eternity to compile.

Merge request reports