When using -fprofile-list to selectively applynone of the translation units in the binary have been instrumentation onlyted
to certain files or functionswe shouldn't need to link the profile runtime. However, we may end up with a binary that doesn'tbecause we pass
have any counters in the case where no files were selected.-u__llvm_profile_runtime on Linux and Fuchsia, However,the runtime would still
because on Linuxbe pulled in and Fuchsia, we pass -u__llvm_profile_runtime,incur some overhead. theOn Fuchsia which uses runtime
runtime would still be pulled in and incur some non-trivial overhead,counter relocation, it also means that we cannot reference the bias
especially in the case when the continuous or runtime counter relocation
mode is being used. A better way would be to pull in the profile runtime
only when needed by declaring the __llvm_profile_runtime symbol in the
translation unit only when neededvariable unconditionally.
This approach was already used prior to 9a041a75221ca, but we changed itchange modifies the InstrProfiling pass to pull in the profile
to always generateruntime only when needed by declaring the __llvm_profile_runtime due to a TAPI limitation.e symbol
Since TAPI is only used on Mach-O platforms,in the translation unit only when needed. we could use the earlyFor now we restrict this only
emission of __llvm_profile_runtime there,for Fuchsia, but this can be later expanded to other platforms. and on other platforms weThis
could change back to the earlier approach where the symbol is generatedapproach was already used prior to 9a041a75221ca, but we changed it
later only when needed. We can stop passing -uto always generate the __llvm_profile_runtime toe due to a TAPI limitation,
the linker on Linux and Fuchsia since the generated undefined symbol inbut that limitation may no longer apply, and it certainly doesn't apply
each translation unit that needed it serves the same purposeon platforms like Fuchsia.