On 10/11/2020 11:27, visitor x via Gcc-help wrote: > I got that compilers will assign some local variable to registers rather than stack for performance reason, while which variable depends on the compiler. I also found there is a calling convention on x64 that the first six arguments are passed to register (when the class is INTEGER). > > However, I got almost nothing about the rest of the case. I am aware that compilers are free to arrange variables in both stack and registers, but what pricinple or specification will they follow? None, really. Optimizing compilers don't really care about variables once the initial transalation has been done, but about values. https://en.wikipedia.org/wiki/Static_single_assignment_form may help. > Is there any materials about gcc's behavior on deciding which variables should be kept in registers? Or any other hint to find variables stored in register from a bianry? It's more complicated than that. Not only can local variables be assigned to registers, then can be assigned to different registers at differentt times. Not only that, but local variables can be eliminated completely or split into multiple copies in different registers. -- Andrew Haley (he/him) Java Platform Lead Engineer Red Hat UK Ltd. <https://www.redhat.com> https://keybase.io/andrewhaley EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671