I was just wondering if its possible to change the size of a function frame by changing the order of vars/consts. I’m guessing the answer is no meaning they’re sorted by alignment and then declaration order? Maybe its not as simple as yes or no, perhaps different by optimization level? Maybe backend and target come into play?
1 Like
That is an optimisation detail decided by the backend.
And it is certainly, at least with LLVM, more complicated than that. The compiler may reuse memory after a variable is no longer used, and some may never go on the stack, only existing in registers or being removed completely.
3 Likes
Thanks. I suspected it wouldn’t be simple. Usual benchmarking and looking at generated code would be the way to try to optimize I guess. Note that I don’t want or need to do this kind of optimization. I’m mostly just wondering.