On ELF, the D103372 optimization can apply to more cases. There are two
prerequisites for making __profd_ private:
- __profc_ keeps __profd_ live under compiler/linker GC
- __profd_ is not referenced by code
The first is satisfied because all counters/data are in a section group (either
comdat any or comdat noduplicates). The second requires that the function
does not use value profiling.
Regarding the second point: __profd_ may be referenced by other text sections
due to inlining. There will be a linker error if a prevailing text section
references the non-prevailing local symbol.
With this change, a stage 2 (-DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_BUILD_INSTRUMENTED=IR)
clang is 4.2% smaller (1-169620032/177066968).
should this code by guarded by whether value profile is enabled?