llvm.org GIT mirror llvm / 1d1bfde
FunctionImport: Remove the -disable-force-link-odr flag and change importFunctions to never force link. This removes some functionality that was only being used by tests. Differential Revision: https://reviews.llvm.org/D29439 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293919 91177308-0d34-0410-b5e6-96231b3b80d8 Peter Collingbourne 2 years ago
3 changed file(s) with 7 addition(s) and 25 deletion(s). Raw diff Collapse all Expand all
5252 : Index(Index), ModuleLoader(std::move(ModuleLoader)) {}
5353
5454 /// Import functions in Module \p M based on the supplied import list.
55 /// \p ForceImportReferencedDiscardableSymbols will set the ModuleLinker in
56 /// a mode where referenced discarable symbols in the source modules will be
57 /// imported as well even if they are not present in the ImportList.
5855 Expected
59 importFunctions(Module &M, const ImportMapTy &ImportList,
60 bool ForceImportReferencedDiscardableSymbols = false);
56 importFunctions(Module &M, const ImportMapTy &ImportList);
6157
6258 private:
6359 /// The summaries index used to trigger importing.
7373
7474 static cl::opt ComputeDead("compute-dead", cl::init(true), cl::Hidden,
7575 cl::desc("Compute dead symbols"));
76
77 // Temporary allows the function import pass to disable always linking
78 // referenced discardable symbols.
79 static cl::opt
80 DontForceImportReferencedDiscardableSymbols("disable-force-link-odr",
81 cl::init(false), cl::Hidden);
8276
8377 static cl::opt EnableImportMetadata(
8478 "enable-import-metadata", cl::init(
665659 // index.
666660 //
667661 Expected FunctionImporter::importFunctions(
668 Module &DestModule, const FunctionImporter::ImportMapTy &ImportList,
669 bool ForceImportReferencedDiscardableSymbols) {
662 Module &DestModule, const FunctionImporter::ImportMapTy &ImportList) {
670663 DEBUG(dbgs() << "Starting import for Module "
671664 << DestModule.getModuleIdentifier() << "\n");
672665 unsigned ImportedCount = 0;
780773 }
781774
782775 // Instruct the linker that the client will take care of linkonce resolution
783 unsigned Flags = Linker::Flags::None;
784 if (!ForceImportReferencedDiscardableSymbols)
785 Flags |= Linker::Flags::DontForceLinkLinkonceODR;
776 unsigned Flags = Linker::Flags::DontForceLinkLinkonceODR;
786777
787778 if (TheLinker.linkInModule(std::move(SrcModule), Flags, &GlobalsToImport))
788779 report_fatal_error("Function Import: link error");
844835 return loadFile(Identifier, M.getContext());
845836 };
846837 FunctionImporter Importer(*Index, ModuleLoader);
847 Expected Result = Importer.importFunctions(
848 M, ImportList, !DontForceImportReferencedDiscardableSymbols);
838 Expected Result = Importer.importFunctions(M, ImportList);
849839
850840 // FIXME: Probably need to propagate Errors through the pass manager.
851841 if (!Result) {
33 ; RUN: llvm-lto -thinlto -print-summary-global-ids -o %t3 %t.bc %t2.bc 2>&1 | FileCheck %s --check-prefix=GUID
44
55 ; Do the import now
6 ; RUN: opt -disable-force-link-odr -function-import -stats -print-imports -enable-import-metadata -summary-file %t3.thinlto.bc %t.bc -S 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIMDEF
6 ; RUN: opt -function-import -stats -print-imports -enable-import-metadata -summary-file %t3.thinlto.bc %t.bc -S 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIMDEF
77 ; Try again with new pass manager
8 ; RUN: opt -disable-force-link-odr -passes='function-import' -stats -print-imports -enable-import-metadata -summary-file %t3.thinlto.bc %t.bc -S 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIMDEF
8 ; RUN: opt -passes='function-import' -stats -print-imports -enable-import-metadata -summary-file %t3.thinlto.bc %t.bc -S 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIMDEF
99 ; "-stats" requires +Asserts.
1010 ; REQUIRES: asserts
1111
1212 ; Test import with smaller instruction limit
13 ; RUN: opt -disable-force-link-odr -function-import -enable-import-metadata -summary-file %t3.thinlto.bc %t.bc -import-instr-limit=5 -S | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIM5
13 ; RUN: opt -function-import -enable-import-metadata -summary-file %t3.thinlto.bc %t.bc -import-instr-limit=5 -S | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIM5
1414 ; INSTLIM5-NOT: @staticfunc.llvm.
15
16 ; Test import with smaller instruction limit and without the -disable-force-link-odr
17 ; RUN: opt -function-import -summary-file %t3.thinlto.bc %t.bc -import-instr-limit=5 -S | FileCheck %s --check-prefix=INSTLIM5ODR
18 ; INSTLIM5ODR: define linkonce_odr void @linkonceodr() {
1915
2016
2117 define i32 @main() #0 {