llvm.org GIT mirror llvm / c58f672
LTO: Do summary-based prevailing symbol resolution at --lto-O0. Prevailing symbol resolution is necessary for correctness. Without this we can end up dropping a referenced linkonce symbol from the link. Differential Revision: https://reviews.llvm.org/D33570 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303939 91177308-0d34-0410-b5e6-96231b3b80d8 Peter Collingbourne 3 years ago
2 changed file(s) with 24 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
10011001 ExportedGUIDs.insert(GUID);
10021002 }
10031003
1004 auto isPrevailing = [&](GlobalValue::GUID GUID,
1005 const GlobalValueSummary *S) {
1006 return ThinLTO.PrevailingModuleForGUID[GUID] == S->modulePath();
1007 };
10081004 auto isExported = [&](StringRef ModuleIdentifier, GlobalValue::GUID GUID) {
10091005 const auto &ExportList = ExportLists.find(ModuleIdentifier);
10101006 return (ExportList != ExportLists.end() &&
10121008 ExportedGUIDs.count(GUID);
10131009 };
10141010 thinLTOInternalizeAndPromoteInIndex(ThinLTO.CombinedIndex, isExported);
1015
1016 auto recordNewLinkage = [&](StringRef ModuleIdentifier,
1017 GlobalValue::GUID GUID,
1018 GlobalValue::LinkageTypes NewLinkage) {
1019 ResolvedODR[ModuleIdentifier][GUID] = NewLinkage;
1020 };
1021
1022 thinLTOResolveWeakForLinkerInIndex(ThinLTO.CombinedIndex, isPrevailing,
1023 recordNewLinkage);
1024 }
1011 }
1012
1013 auto isPrevailing = [&](GlobalValue::GUID GUID,
1014 const GlobalValueSummary *S) {
1015 return ThinLTO.PrevailingModuleForGUID[GUID] == S->modulePath();
1016 };
1017 auto recordNewLinkage = [&](StringRef ModuleIdentifier,
1018 GlobalValue::GUID GUID,
1019 GlobalValue::LinkageTypes NewLinkage) {
1020 ResolvedODR[ModuleIdentifier][GUID] = NewLinkage;
1021 };
1022 thinLTOResolveWeakForLinkerInIndex(ThinLTO.CombinedIndex, isPrevailing,
1023 recordNewLinkage);
10251024
10261025 std::unique_ptr BackendProc =
10271026 ThinLTO.Backend(Conf, ThinLTO.CombinedIndex, ModuleToDefinedGVSummaries,
0 ; RUN: opt -module-summary -o %t %s
1 ; RUN: llvm-lto2 run %t -O0 -r %t,foo,px -o %t2
2 ; RUN: llvm-nm %t2.0 | FileCheck %s
3
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
6
7 ; CHECK: W foo
8 define linkonce_odr void @foo() {
9 ret void
10 }