[all-commits] [llvm/llvm-project] 9ab9a9: [InstrProfiling] Keep profd non-private for non-re...
Fangrui Song via All-commits
all-commits at lists.llvm.org
Tue Aug 24 20:14:17 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 9ab9a9595b1bbcf360de619f7c9c17f4340caa52
https://github.com/llvm/llvm-project/commit/9ab9a9595b1bbcf360de619f7c9c17f4340caa52
Author: Fangrui Song <i at maskray.me>
Date: 2021-08-24 (Tue, 24 Aug 2021)
Changed paths:
M llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
M llvm/test/Transforms/PGOProfile/comdat.ll
Log Message:
-----------
[InstrProfiling] Keep profd non-private for non-renamable comdat functions
The NS==0 condition used by D103717 missed a corner case: if the current copy
does not have a hash suffix (e.g. weak_odr), a copy with value profiling (with a
different CFG) may exist. This is super rare, but is possible with pre-inlining
PGO instrumentation (which can make a weak_odr function inlines its callees
differently, sometimes with value profiling while sometimes without).
If the current copy with private profd is prevailing, the non-prevailing copy
may get an undefined symbol if a caller inlining the non-prevailing function
references its profd. If the other copy with non-private profd is prevailing,
the current copy may cause a "relocation to discarded section" linker error.
The fix is straightforward: just keep non-private profd in such a `DataReferencedByCode` case.
With this change, a stage 2 (`-DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_BUILD_INSTRUMENTED=IR`)
clang is 0.08% larger (172431496/172286720-1).
`stat -c %s **/*.o | awk '{s+=$1}END{print s}' is 0.026% larger.
The majority of D103717's benefits remains.
Reviewed By: xur
Differential Revision: https://reviews.llvm.org/D108432
More information about the All-commits
mailing list