This is an archive of the discontinued LLVM Phabricator instance.

[InstrProf] Disable marking COMDAT profd variable as private linkage
Needs ReviewPublic

Authored by xur on Oct 6 2022, 10:49 PM.

Details

Reviewers
MaskRay
rnk
Summary

It is not safe to set private linkage for the profd variable created for the COMDAT function. For the LTO build where the COMDAT group might be dissolved. If that happens, we will have multiple "profd" in the final binary and result in multiple function counters for the same function.

This fixes PR58215: https://github.com/llvm/llvm-project/issues/58215.

Diff Detail

Event Timeline

xur created this revision.Oct 6 2022, 10:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 6 2022, 10:49 PM
xur requested review of this revision.Oct 6 2022, 10:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 6 2022, 10:49 PM

I agree that the current setup is problematic for ThinLTO. I think we can retain the current size optimization of private profd (suppressing the symbol table entry). D135427 tries to fix this on the FunctionImport side.
clang -O2 -fuse-ld=lld -fprofile-generate=./t m1.o m2.o -flto=thin -o t_gen will work.