3 ms·
Does providing a hint to the compiler using the register keyword address the issue sufficiently?
by 10000truths 4y ago
Does providing a hint to the compiler using the register keyword address the issue sufficiently?
- haberman 4y agoNo, most compilers ignore the register keyword, see: https://stackoverflow.com/a/10675111 https://stackoverflow.com/a/10675111
- JonChesterfield 4y agoNearly. You need register and to also pass them into (potentially no-op) inline asm. `register int v("eax")` iirc, but it's been years since I did this. The 'register' is indeed largely ignored, but it has the additional somewhat documented meaning of 'when this variable goes into inline asm, it needs to be in that register'. In between asm blocks it can be elsewhere - stack or whatever - but it still gives the regalloc a really clear guide to work from.
- lifthrasiir 4y agoIt's `register int v asm("eax")`. However they are very easily elided, especially after higher optimization levels; compilers are very open about this [1]. [1] https://gcc.gnu.org/onlinedocs/gcc/Local-Register-Variables.html#Local-Register-Variables https://gcc.gnu.org/onlinedocs/gcc/Local-Register-Variables....
- deleted 4y ago[deleted]