Do they work across different object files? Do they work across different DLLs?
I know this depends on the compiler. I'm curious if there are any compilers and optimization settings that will make this work.
Do they work across different object files? Do they work across different DLLs?
I know this depends on the compiler. I'm curious if there are any compilers and optimization settings that will make this work.
Copyright © 2021 Jogjafile Inc.
Normally, yes, but in principle, using Link-Time-Optimization (
-flto
for GCC/Clang compilers and linkers) or Link-Time-Code-Generation (/LTCG
and/GL
for MSVC's compiler and linker), the compiler and linker can leverage their shared knowledge and perhaps inline code and elide copies. GCC's manual states:Note this will not work with DLLs, because a shared library's code is fixed and already fully compiled.
RVO only needs information about the function itself (as it constructs the function's return value in-place instead of copying/moving on
return
. This will likely work without the aboce options.