Hacker News new | ask | show | jobs
by rstuart4133 1703 days ago
I think their reasoning appears earlier:

> When a C compiler decides to not inline, there is likely a good reason. For example, inlining would reuse a register which require to save/restore the register value on the stack and so increase the stack memory usage or be less efficient.

And ... that removes all doubt. They are wrong. If a calculation requires an extra register, doing a function call won't conjure it out of thin air. It has to spill the register too, and it will push the PC along with it.

It's still possible a doing function call rather than inlining will speed up code on modern CPU's. The repeated code the inlining generates extra demands on the caches.

1 comments

You might not be considering the big picture. If the extra register is used in a callee that wasn't inlined, that slot on the stack will be free to be reused by other callees that aren't inlined. So inlining into a function with multiple callees can increase the peak stack usage for the entire callgraph.