[InstrProfiling] Use llvm.compiler.used if applicable for Mach-O
authorFangrui Song <i@maskray.me>
Wed, 1 Sep 2021 21:46:51 +0000 (14:46 -0700)
committerFangrui Song <i@maskray.me>
Wed, 1 Sep 2021 21:46:51 +0000 (14:46 -0700)
commit68745a557e9454c0f54011b9eea139f04b699b69
treeb29dc8d64b80ad84765aaa7b99122f4f883d4717
parent4ef88031f52f7c21356295e609ecea3c10d29d9f
[InstrProfiling] Use llvm.compiler.used if applicable for Mach-O

Similar to D97585.

D25456 used `S_ATTR_LIVE_SUPPORT` to ensure the data variable will be retained
or discarded as a unit with the counter variable, so llvm.compiler.used is
sufficient. It allows ld to dead strip unneeded profc and profd variables.

Reviewed By: vsk

Differential Revision: https://reviews.llvm.org/D105445
compiler-rt/test/profile/Darwin/coverage-linkage.cpp [new file with mode: 0644]
compiler-rt/test/profile/Darwin/lit.local.cfg.py [new file with mode: 0644]
llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
llvm/test/Instrumentation/InstrProfiling/profiling.ll