문제

I was wondering, it is possible to explicitly specify a custom calling convention, but considering the maturity and amount of optimizations found in the compiler, when no calling convention is specified, can I expect the compiler to pick the best one for the particular function, for example if parameters are few and primitive use fastcall and so on...

도움이 되었습니까?

해결책

It is a "convention" for a reason. Everybody has to follow the convention or you couldn't call your function from another module.

However, if the function is not visible then GCC has options. It may inline the function or call it however it wants to. It might even split it into "hot" and "cold" parts and inline the hot code path. That usually only happens when building with profile guided optimization.

If you want GCC to make optimizations like that, work on hiding your functions. If you are building an executable look at -fwhole-program. If you are building libraries look at -fvisibility=hidden. Also look into -flto.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top