4 ms·
Six of the parameters use registers here. the `lea` is putting the sum of the first two into `eax`, then the rest accumulate more adds into `eax`. Only the last
by nikki93 6y ago
Six of the parameters use registers here. the `lea` is putting the sum of the first two into `eax`, then the rest accumulate more adds into `eax`. Only the last 3 parameters are reading from stack memory (the `dword ptr [*]` stuff).
In any case you don't get to actually see the passing at the callsite because the result `45` is inlined into `main()`. :)
- flohofwoe 6y agoThanks for the clarification (also to archgoon). To your last point, I should have used -O1 instead of -O2, this also makes it clear what happens on the callsite.
- nikki93 6y agoAnother approach is to use a `volatile` function pointer: https://www.godbolt.org/z/e6GM93 https://www.godbolt.org/z/e6GM93 -- That way you get to keep other optimizations from `-O3` without inlining the function call itself.
- ddalcino 6y agoYou don’t need to lower the optimization level to see what happens at the call site: you can turn the function ‘blub’ into a function prototype. The optimizer cannot in-line your code if it isn’t available. https://www.godbolt.org/z/sj11rc https://www.godbolt.org/z/sj11rc