llvm.org GIT mirror llvm / 8e0fce8
[PGO] Fix __llvm_profile_raw_version linkage in MACHO IR instrumentation generates a COMDAT symbol __llvm_profile_raw_version to overwrite the same symbol in profile run-time to distinguish IR profiles from Clang generated profiles. In MACHO, LinkOnceODR linkage is used due to the lack of COMDAT support. But LinkOnceODR linkage might have .weak_def_can_be_hidden assembly directive, while the weak variable in run-time has a .weak_definition directive. Linker will not merge these two symbols even they have the same name. The end result is IR profiles are not properly flagged in MACHO. This patch changes the linkage for __llvm_profile_raw_version in each module to LinkOnceAny so that it has same .weak_definition directive as in the run-time. Differential Revision: http://reviews.llvm.org/D20078 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268969 91177308-0d34-0410-b5e6-96231b3b80d8 Rong Xu 3 years ago
2 changed file(s) with 10 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
775775 IRLevelVersionVariable->setVisibility(GlobalValue::DefaultVisibility);
776776 Triple TT(M.getTargetTriple());
777777 if (TT.isOSBinFormatMachO())
778 IRLevelVersionVariable->setLinkage(GlobalValue::LinkOnceODRLinkage);
778 IRLevelVersionVariable->setLinkage(GlobalValue::LinkOnceAnyLinkage);
779779 else
780780 IRLevelVersionVariable->setComdat(M.getOrInsertComdat(
0 ; RUN: opt < %s -mtriple=x86_64-apple-macosx10.11.0 -pgo-instr-gen -instrprof -S | llc | FileCheck %s --check-prefix=MACHO-DIRECTIVE
2 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
4 ; MACHO-DIRECTIVE: .weak_definition ___llvm_profile_raw_version
5 define i32 @test_macho(i32 %i) {
6 entry:
7 ret i32 %i
8 }