[profile] Move __llvm_profile_raw_version into a separate file
authorMin-Yih Hsu <minyihh@uci.edu>
Fri, 10 Jul 2020 16:40:09 +0000 (09:40 -0700)
committerMin-Yih Hsu <minyihh@uci.edu>
Thu, 16 Jul 2020 23:02:04 +0000 (16:02 -0700)
commit0f6220ddd6c751ff83fa1afe464ff0737ab0bf07
treef1de5498b0bf092ab08c852e995332276e6e2352
parent2cf3458c3b2937f34ac91cbd95291ae3aef28d82
[profile] Move __llvm_profile_raw_version into a separate file

Similar to the reason behind moving __llvm_profile_filename into a
separate file[1]. When users try to use Full LTO with BFD linker to
generate IR level PGO profile, the __llvm_profile_raw_version variable,
which is used for marking instrumentation level, generated by frontend
would somehow conflict with the weak symbol provided by profiling
runtime.

In most of the cases, BFD linkers will pick profiling runtime's weak symbol
as the real definition and thus generate the incorrect instrumentation
level metadata in the final executables.

Moving __llvm_profile_raw_version into a separate file would make
linkers not seeing the weak symbol in the archive unless the frontend
doesn't generate one.

[1] https://reviews.llvm.org/D34797

Differential Revision: https://reviews.llvm.org/D83967
compiler-rt/lib/profile/CMakeLists.txt
compiler-rt/lib/profile/InstrProfiling.c
compiler-rt/lib/profile/InstrProfilingVersionVar.c [new file with mode: 0644]
compiler-rt/test/profile/instrprof-lto-pgogen.c [new file with mode: 0644]