llvm.org GIT mirror llvm / 6588114
Revert [ThinLTO] Fix ThinLTOCodegenerator to export llvm.used symbols This reverts r357931 (git commit 8b70a5c11e08116955a875b9085433f14737bcaf) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357932 91177308-0d34-0410-b5e6-96231b3b80d8 Steven Wu 1 year, 7 months ago
7 changed file(s) with 106 addition(s) and 191 deletion(s). Raw diff Collapse all Expand all
130130 using irsymtab::Symbol::isWeak;
131131 using irsymtab::Symbol::isIndirect;
132132 using irsymtab::Symbol::getName;
133 using irsymtab::Symbol::getIRName;
134133 using irsymtab::Symbol::getVisibility;
135134 using irsymtab::Symbol::canBeOmittedFromSymbolTable;
136135 using irsymtab::Symbol::isTLS;
160159
161160 // Returns a table with all the comdats used by this file.
162161 ArrayRef getComdatTable() const { return ComdatTable; }
163
164 // Returns the only BitcodeModule from InputFile.
165 BitcodeModule &getSingleBitcodeModule();
166162
167163 private:
168164 ArrayRef module_symbols(unsigned I) const {
1818 #include "llvm/ADT/StringSet.h"
1919 #include "llvm/ADT/Triple.h"
2020 #include "llvm/IR/ModuleSummaryIndex.h"
21 #include "llvm/LTO/LTO.h"
2221 #include "llvm/Support/CachePruning.h"
2322 #include "llvm/Support/CodeGen.h"
2423 #include "llvm/Support/MemoryBuffer.h"
3029 class StringRef;
3130 class LLVMContext;
3231 class TargetMachine;
32
33 /// Wrapper around MemoryBufferRef, owning the identifier
34 class ThinLTOBuffer {
35 std::string OwnedIdentifier;
36 StringRef Buffer;
37
38 public:
39 ThinLTOBuffer(StringRef Buffer, StringRef Identifier)
40 : OwnedIdentifier(Identifier), Buffer(Buffer) {}
41
42 MemoryBufferRef getMemBuffer() const {
43 return MemoryBufferRef(Buffer,
44 {OwnedIdentifier.c_str(), OwnedIdentifier.size()});
45 }
46 StringRef getBuffer() const { return Buffer; }
47 StringRef getBufferIdentifier() const { return OwnedIdentifier; }
48 };
3349
3450 /// Helper to gather options relevant to the target machine creation
3551 struct TargetMachineBuilder {
250266 * and additionally resolve weak and linkonce symbols.
251267 * Index is updated to reflect linkage changes from weak resolution.
252268 */
253 void promote(Module &Module, ModuleSummaryIndex &Index,
254 const lto::InputFile &File);
269 void promote(Module &Module, ModuleSummaryIndex &Index);
255270
256271 /**
257272 * Compute and emit the imported files for module at \p ModulePath.
258273 */
259274 void emitImports(Module &Module, StringRef OutputName,
260 ModuleSummaryIndex &Index,
261 const lto::InputFile &File);
275 ModuleSummaryIndex &Index);
262276
263277 /**
264278 * Perform cross-module importing for the module identified by
265279 * ModuleIdentifier.
266280 */
267 void crossModuleImport(Module &Module, ModuleSummaryIndex &Index,
268 const lto::InputFile &File);
281 void crossModuleImport(Module &Module, ModuleSummaryIndex &Index);
269282
270283 /**
271284 * Compute the list of summaries needed for importing into module.
272285 */
273286 void gatherImportedSummariesForModule(
274287 Module &Module, ModuleSummaryIndex &Index,
275 std::map &ModuleToSummariesForIndex,
276 const lto::InputFile &File);
288 std::map &ModuleToSummariesForIndex);
277289
278290 /**
279291 * Perform internalization. Index is updated to reflect linkage changes.
280292 */
281 void internalize(Module &Module, ModuleSummaryIndex &Index,
282 const lto::InputFile &File);
293 void internalize(Module &Module, ModuleSummaryIndex &Index);
283294
284295 /**
285296 * Perform post-importing ThinLTO optimizations.
301312
302313 /// Vector holding the input buffers containing the bitcode modules to
303314 /// process.
304 std::vector<std::unique_ptr> Modules;
315 std::vector<ThinLTOBuffer> Modules;
305316
306317 /// Set of symbols that need to be preserved outside of the set of bitcode
307318 /// files.
419419 return Mods[0].getModuleIdentifier();
420420 }
421421
422 BitcodeModule &InputFile::getSingleBitcodeModule() {
423 assert(Mods.size() == 1 && "Expect only one bitcode module");
424 return Mods[0];
425 }
426
427422 LTO::RegularLTOState::RegularLTOState(unsigned ParallelCodeGenParallelismLevel,
428423 Config &Conf)
429424 : ParallelCodeGenParallelismLevel(ParallelCodeGenParallelismLevel),
134134 }
135135 }
136136
137 static StringMap
138 generateModuleMap(std::vector> &Modules) {
139 StringMap ModuleMap;
140 for (auto &M : Modules) {
141 assert(ModuleMap.find(M->getName()) == ModuleMap.end() &&
137 static StringMap
138 generateModuleMap(const std::vector &Modules) {
139 StringMap ModuleMap;
140 for (auto &ModuleBuffer : Modules) {
141 assert(ModuleMap.find(ModuleBuffer.getBufferIdentifier()) ==
142 ModuleMap.end() &&
142143 "Expect unique Buffer Identifier");
143 ModuleMap[M->getName()] = M.get();
144 ModuleMap[ModuleBuffer.getBufferIdentifier()] = ModuleBuffer.getMemBuffer();
144145 }
145146 return ModuleMap;
146147 }
173174 }
174175 }
175176
176 static std::unique_ptr loadModuleFromInput(lto::InputFile *Input,
177 LLVMContext &Context,
178 bool Lazy,
179 bool IsImporting) {
180 auto &Mod = Input->getSingleBitcodeModule();
177 static std::unique_ptr
178 loadModuleFromBuffer(const MemoryBufferRef &Buffer, LLVMContext &Context,
179 bool Lazy, bool IsImporting) {
181180 SMDiagnostic Err;
182181 Expected> ModuleOrErr =
183 Lazy ? Mod.getLazyModule(Context,
184 /* ShouldLazyLoadMetadata */ true, IsImporting)
185 : Mod.parseModule(Context);
182 Lazy
183 ? getLazyBitcodeModule(Buffer, Context,
184 /* ShouldLazyLoadMetadata */ true, IsImporting)
185 : parseBitcodeFile(Buffer, Context);
186186 if (!ModuleOrErr) {
187187 handleAllErrors(ModuleOrErr.takeError(), [&](ErrorInfoBase &EIB) {
188 SMDiagnostic Err = SMDiagnostic(Mod.getModuleIdentifier(),
188 SMDiagnostic Err = SMDiagnostic(Buffer.getBufferIdentifier(),
189189 SourceMgr::DK_Error, EIB.message());
190190 Err.print("ThinLTO", errs());
191191 });
193193 }
194194 if (!Lazy)
195195 verifyLoadedModule(*ModuleOrErr.get());
196 return std::move(*ModuleOrErr);
196 return std::move(ModuleOrErr.get());
197197 }
198198
199199 static void
200200 crossImportIntoModule(Module &TheModule, const ModuleSummaryIndex &Index,
201 StringMap<lto::InputFile*> &ModuleMap,
201 StringMap<MemoryBufferRef> &ModuleMap,
202202 const FunctionImporter::ImportMapTy &ImportList) {
203203 auto Loader = [&](StringRef Identifier) {
204 auto &Input = ModuleMap[Identifier];
205 return loadModuleFromInput(Input, TheModule.getContext(),
206 /*Lazy=*/true, /*IsImporting*/ true);
204 return loadModuleFromBuffer(ModuleMap[Identifier], TheModule.getContext(),
205 /*Lazy=*/true, /*IsImporting*/ true);
207206 };
208207
209208 FunctionImporter Importer(Index, Loader);
246245 PMB.populateThinLTOPassManager(PM);
247246
248247 PM.run(TheModule);
249 }
250
251 static void
252 addUsedSymbolToPreservedGUID(const lto::InputFile &File,
253 DenseSet &PreservedGUID) {
254 for (const auto &Sym : File.symbols()) {
255 if (Sym.isUsed())
256 PreservedGUID.insert(GlobalValue::getGUID(Sym.getIRName()));
257 }
258248 }
259249
260250 // Convert the PreservedSymbols map from "Name" based to "GUID" based.
390380
391381 static std::unique_ptr
392382 ProcessThinLTOModule(Module &TheModule, ModuleSummaryIndex &Index,
393 StringMap<lto::InputFile *> &ModuleMap, TargetMachine &TM,
383 StringMap<MemoryBufferRef> &ModuleMap, TargetMachine &TM,
394384 const FunctionImporter::ImportMapTy &ImportList,
395385 const FunctionImporter::ExportSetTy &ExportList,
396386 const DenseSet &GUIDPreservedSymbols,
497487 } // end anonymous namespace
498488
499489 void ThinLTOCodeGenerator::addModule(StringRef Identifier, StringRef Data) {
500 MemoryBufferRef Buffer(Data, Identifier);
501
502 auto InputOrError = lto::InputFile::create(Buffer);
503 if (!InputOrError)
504 report_fatal_error("ThinLTO cannot create input file");
505
506 auto TripleStr = (*InputOrError)->getTargetTriple();
490 ThinLTOBuffer Buffer(Data, Identifier);
491 LLVMContext Context;
492 StringRef TripleStr;
493 ErrorOr TripleOrErr = expectedToErrorOrAndEmitErrors(
494 Context, getBitcodeTargetTriple(Buffer.getMemBuffer()));
495
496 if (TripleOrErr)
497 TripleStr = *TripleOrErr;
498
507499 Triple TheTriple(TripleStr);
508500
509501 if (Modules.empty())
515507 initTMBuilder(TMBuilder, Triple(TMBuilder.TheTriple.merge(TheTriple)));
516508 }
517509
518 Modules.emplace_back(std::move(*InputOrError));
510 Modules.push_back(Buffer);
519511 }
520512
521513 void ThinLTOCodeGenerator::preserveSymbol(StringRef Name) {
556548 std::unique_ptr CombinedIndex =
557549 llvm::make_unique(/*HaveGVs=*/false);
558550 uint64_t NextModuleId = 0;
559 for (auto &Mod : Modules) {
560 auto &M = Mod->getSingleBitcodeModule();
561 if (Error Err =
562 M.readSummary(*CombinedIndex, Mod->getName(), NextModuleId++)) {
551 for (auto &ModuleBuffer : Modules) {
552 if (Error Err = readModuleSummaryIndex(ModuleBuffer.getMemBuffer(),
553 *CombinedIndex, NextModuleId++)) {
563554 // FIXME diagnose
564555 logAllUnhandledErrors(
565556 std::move(Err), errs(),
601592 * Perform promotion and renaming of exported internal functions.
602593 * Index is updated to reflect linkage changes from weak resolution.
603594 */
604 void ThinLTOCodeGenerator::promote(Module &TheModule, ModuleSummaryIndex &Index,
605 const lto::InputFile &File) {
595 void ThinLTOCodeGenerator::promote(Module &TheModule,
596 ModuleSummaryIndex &Index) {
606597 auto ModuleCount = Index.modulePaths().size();
607598 auto ModuleIdentifier = TheModule.getModuleIdentifier();
608599
613604 // Convert the preserved symbols set from string to GUID
614605 auto GUIDPreservedSymbols = computeGUIDPreservedSymbols(
615606 PreservedSymbols, Triple(TheModule.getTargetTriple()));
616
617 // Add used symbol to the preserved symbols.
618 addUsedSymbolToPreservedGUID(File, GUIDPreservedSymbols);
619607
620608 // Compute "dead" symbols, we don't want to import/export these!
621609 computeDeadSymbolsInIndex(Index, GUIDPreservedSymbols);
630618 StringMap> ResolvedODR;
631619 resolvePrevailingInIndex(Index, ResolvedODR);
632620
621 thinLTOResolvePrevailingInModule(
622 TheModule, ModuleToDefinedGVSummaries[ModuleIdentifier]);
623
633624 // Promote the exported values in the index, so that they are promoted
634625 // in the module.
635626 internalizeAndPromoteInIndex(ExportLists, GUIDPreservedSymbols, Index);
636627
637628 promoteModule(TheModule, Index);
638
639 thinLTOResolvePrevailingInModule(
640 TheModule, ModuleToDefinedGVSummaries[ModuleIdentifier]);
641629 }
642630
643631 /**
644632 * Perform cross-module importing for the module identified by ModuleIdentifier.
645633 */
646634 void ThinLTOCodeGenerator::crossModuleImport(Module &TheModule,
647 ModuleSummaryIndex &Index,
648 const lto::InputFile &File) {
635 ModuleSummaryIndex &Index) {
649636 auto ModuleMap = generateModuleMap(Modules);
650637 auto ModuleCount = Index.modulePaths().size();
651638
656643 // Convert the preserved symbols set from string to GUID
657644 auto GUIDPreservedSymbols = computeGUIDPreservedSymbols(
658645 PreservedSymbols, Triple(TheModule.getTargetTriple()));
659
660 addUsedSymbolToPreservedGUID(File, GUIDPreservedSymbols);
661646
662647 // Compute "dead" symbols, we don't want to import/export these!
663648 computeDeadSymbolsInIndex(Index, GUIDPreservedSymbols);
677662 */
678663 void ThinLTOCodeGenerator::gatherImportedSummariesForModule(
679664 Module &TheModule, ModuleSummaryIndex &Index,
680 std::map &ModuleToSummariesForIndex,
681 const lto::InputFile &File) {
665 std::map &ModuleToSummariesForIndex) {
682666 auto ModuleCount = Index.modulePaths().size();
683667 auto ModuleIdentifier = TheModule.getModuleIdentifier();
684668
689673 // Convert the preserved symbols set from string to GUID
690674 auto GUIDPreservedSymbols = computeGUIDPreservedSymbols(
691675 PreservedSymbols, Triple(TheModule.getTargetTriple()));
692
693 addUsedSymbolToPreservedGUID(File, GUIDPreservedSymbols);
694676
695677 // Compute "dead" symbols, we don't want to import/export these!
696678 computeDeadSymbolsInIndex(Index, GUIDPreservedSymbols);
710692 * Emit the list of files needed for importing into module.
711693 */
712694 void ThinLTOCodeGenerator::emitImports(Module &TheModule, StringRef OutputName,
713 ModuleSummaryIndex &Index,
714 const lto::InputFile &File) {
695 ModuleSummaryIndex &Index) {
715696 auto ModuleCount = Index.modulePaths().size();
716697 auto ModuleIdentifier = TheModule.getModuleIdentifier();
717698
722703 // Convert the preserved symbols set from string to GUID
723704 auto GUIDPreservedSymbols = computeGUIDPreservedSymbols(
724705 PreservedSymbols, Triple(TheModule.getTargetTriple()));
725
726 addUsedSymbolToPreservedGUID(File, GUIDPreservedSymbols);
727706
728707 // Compute "dead" symbols, we don't want to import/export these!
729708 computeDeadSymbolsInIndex(Index, GUIDPreservedSymbols);
750729 * Perform internalization. Index is updated to reflect linkage changes.
751730 */
752731 void ThinLTOCodeGenerator::internalize(Module &TheModule,
753 ModuleSummaryIndex &Index,
754 const lto::InputFile &File) {
732 ModuleSummaryIndex &Index) {
755733 initTMBuilder(TMBuilder, Triple(TheModule.getTargetTriple()));
756734 auto ModuleCount = Index.modulePaths().size();
757735 auto ModuleIdentifier = TheModule.getModuleIdentifier();
759737 // Convert the preserved symbols set from string to GUID
760738 auto GUIDPreservedSymbols =
761739 computeGUIDPreservedSymbols(PreservedSymbols, TMBuilder.TheTriple);
762
763 addUsedSymbolToPreservedGUID(File, GUIDPreservedSymbols);
764740
765741 // Collect for each module the list of function it defines (GUID -> Summary).
766742 StringMap ModuleToDefinedGVSummaries(ModuleCount);
853829 // Perform only parallel codegen and return.
854830 ThreadPool Pool;
855831 int count = 0;
856 for (auto &Mod : Modules) {
832 for (auto &ModuleBuffer : Modules) {
857833 Pool.async([&](int count) {
858834 LLVMContext Context;
859835 Context.setDiscardValueNames(LTODiscardValueNames);
860836
861837 // Parse module now
862 auto TheModule = loadModuleFromInput(Mod.get(), Context, false,
863 /*IsImporting*/ false);
838 auto TheModule =
839 loadModuleFromBuffer(ModuleBuffer.getMemBuffer(), Context, false,
840 /*IsImporting*/ false);
864841
865842 // CodeGen
866843 auto OutputBuffer = codegenModule(*TheModule, *TMBuilder.create());
903880 auto GUIDPreservedSymbols =
904881 computeGUIDPreservedSymbols(PreservedSymbols, TMBuilder.TheTriple);
905882
906 // Add used symbol from inputs to the preserved symbols.
907 for (const auto &M : Modules)
908 addUsedSymbolToPreservedGUID(*M, GUIDPreservedSymbols);
909
910883 // Compute "dead" symbols, we don't want to import/export these!
911884 computeDeadSymbolsInIndex(*Index, GUIDPreservedSymbols);
912885
939912 // GVSummary and ResolvedODR maps to enable threaded access to these maps
940913 // below.
941914 for (auto &Module : Modules) {
942 auto ModuleIdentifier = Module->getName();
915 auto ModuleIdentifier = Module.getBufferIdentifier();
943916 ExportLists[ModuleIdentifier];
944917 ImportLists[ModuleIdentifier];
945918 ResolvedODR[ModuleIdentifier];
953926 ModulesOrdering.resize(Modules.size());
954927 std::iota(ModulesOrdering.begin(), ModulesOrdering.end(), 0);
955928 llvm::sort(ModulesOrdering, [&](int LeftIndex, int RightIndex) {
956 auto LSize =
957 Modules[LeftIndex]->getSingleBitcodeModule().getBuffer().size();
958 auto RSize =
959 Modules[RightIndex]->getSingleBitcodeModule().getBuffer().size();
929 auto LSize = Modules[LeftIndex].getBuffer().size();
930 auto RSize = Modules[RightIndex].getBuffer().size();
960931 return LSize > RSize;
961932 });
962933
964935 {
965936 ThreadPool Pool(ThreadCount);
966937 for (auto IndexCount : ModulesOrdering) {
967 auto &Mod = Modules[IndexCount];
938 auto &ModuleBuffer = Modules[IndexCount];
968939 Pool.async([&](int count) {
969 auto ModuleIdentifier = Mod->getName();
940 auto ModuleIdentifier = ModuleBuffer.getBufferIdentifier();
970941 auto &ExportList = ExportLists[ModuleIdentifier];
971942
972943 auto &DefinedGVSummaries = ModuleToDefinedGVSummaries[ModuleIdentifier];
1010981 }
1011982
1012983 // Parse module now
1013 auto TheModule = loadModuleFromInput(Mod.get(), Context, false,
1014 /*IsImporting*/ false);
984 auto TheModule =
985 loadModuleFromBuffer(ModuleBuffer.getMemBuffer(), Context, false,
986 /*IsImporting*/ false);
1015987
1016988 // Save temps: original file.
1017989 saveTempBitcode(*TheModule, SaveTempsDir, count, ".0.original.bc");
+0
-10
test/LTO/X86/Inputs/thinlto-internalize-used2.ll less more
None target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
1 target triple = "x86_64-apple-macosx10.15.0"
2
3 define i32 @main() {
4 entry:
5 %call = call i32 @bar()
6 ret i32 0
7 }
8
9 declare i32 @bar()
+0
-21
test/LTO/X86/thinlto-internalize-used.ll less more
None ; RUN: opt -module-summary -o %t.bc %s
1 ; RUN: opt -module-summary -o %t-main.bc %S/Inputs/thinlto-internalize-used2.ll
2 ; RUN: llvm-lto -thinlto-action=thinlink %t.bc %t-main.bc -o %t-index.bc
3 ; RUN: llvm-lto -thinlto-action=promote -thinlto-index %t-index.bc %t.bc -o %t.promote.bc
4 ; RUN: llvm-dis %t.promote.bc -o - | FileCheck %s
5
6 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
7 target triple = "x86_64-apple-macosx10.15.0"
8
9 @llvm.used = appending global [1 x i8*] [i8* bitcast (i32 ()* @foo to i8*)], section "llvm.metadata"
10
11 ; Make sure foo is not internalized.
12 ; CHECK: define i32 @foo()
13 define i32 @foo() {
14 ret i32 0
15 }
16
17 define hidden i32 @bar() {
18 ret i32 0
19 }
20
448448 return ExitOnErr(getModuleSummaryIndexForFile(ThinLTOIndex));
449449 }
450450
451 static std::unique_ptr loadFile(StringRef Filename) {
452 ExitOnError ExitOnErr("llvm-lto: error loading file '" + Filename.str() +
453 "': ");
454 return ExitOnErr(errorOrToExpected(MemoryBuffer::getFileOrSTDIN(Filename)));
455 }
456
457 static std::unique_ptr loadInputFile(MemoryBufferRef Buffer) {
458 ExitOnError ExitOnErr("llvm-lto: error loading input '" +
459 Buffer.getBufferIdentifier().str() + "': ");
460 return ExitOnErr(lto::InputFile::create(Buffer));
461 }
462
463 static std::unique_ptr loadModuleFromInput(lto::InputFile &File,
464 LLVMContext &CTX) {
465 auto &Mod = File.getSingleBitcodeModule();
466 auto ModuleOrErr = Mod.parseModule(CTX);
467 if (!ModuleOrErr) {
468 handleAllErrors(ModuleOrErr.takeError(), [&](ErrorInfoBase &EIB) {
469 SMDiagnostic Err = SMDiagnostic(Mod.getModuleIdentifier(),
470 SourceMgr::DK_Error, EIB.message());
471 Err.print("llvm-lto", errs());
472 });
473 report_fatal_error("Can't load module, abort.");
474 }
475 maybeVerifyModule(**ModuleOrErr);
451 static std::unique_ptr loadModule(StringRef Filename,
452 LLVMContext &Ctx) {
453 SMDiagnostic Err;
454 std::unique_ptr M(parseIRFile(Filename, Err, Ctx));
455 if (!M) {
456 Err.print("llvm-lto", errs());
457 report_fatal_error("Can't load module for file " + Filename);
458 }
459 maybeVerifyModule(*M);
460
476461 if (ThinLTOModuleId.getNumOccurrences()) {
477462 if (InputFilenames.size() != 1)
478463 report_fatal_error("Can't override the module id for multiple files");
479 (*ModuleOrErr)->setModuleIdentifier(ThinLTOModuleId);
480 }
481 return std::move(*ModuleOrErr);
464 M->setModuleIdentifier(ThinLTOModuleId);
465 }
466 return M;
482467 }
483468
484469 static void writeModuleToFile(Module &TheModule, StringRef Filename) {
576561 auto Index = loadCombinedIndex();
577562 for (auto &Filename : InputFilenames) {
578563 LLVMContext Ctx;
579 auto Buffer = loadFile(Filename);
580 auto Input = loadInputFile(Buffer->getMemBufferRef());
581 auto TheModule = loadModuleFromInput(*Input, Ctx);
564 auto TheModule = loadModule(Filename, Ctx);
582565
583566 // Build a map of module to the GUIDs and summary objects that should
584567 // be written to its index.
585568 std::map ModuleToSummariesForIndex;
586 ThinGenerator.gatherImportedSummariesForModule(
587 *TheModule, *Index, ModuleToSummariesForIndex, *Input);
569 ThinGenerator.gatherImportedSummariesForModule(*TheModule, *Index,
570 ModuleToSummariesForIndex);
588571
589572 std::string OutputName = OutputFilename;
590573 if (OutputName.empty()) {
613596 auto Index = loadCombinedIndex();
614597 for (auto &Filename : InputFilenames) {
615598 LLVMContext Ctx;
616 auto Buffer = loadFile(Filename);
617 auto Input = loadInputFile(Buffer->getMemBufferRef());
618 auto TheModule = loadModuleFromInput(*Input, Ctx);
599 auto TheModule = loadModule(Filename, Ctx);
619600 std::string OutputName = OutputFilename;
620601 if (OutputName.empty()) {
621602 OutputName = Filename + ".imports";
622603 }
623 OutputName =
624 getThinLTOOutputFile(OutputName, OldPrefix, NewPrefix);
625 ThinGenerator.emitImports(*TheModule, OutputName, *Index, *Input);
604 OutputName = getThinLTOOutputFile(OutputName, OldPrefix, NewPrefix);
605 ThinGenerator.emitImports(*TheModule, OutputName, *Index);
626606 }
627607 }
628608
640620 auto Index = loadCombinedIndex();
641621 for (auto &Filename : InputFilenames) {
642622 LLVMContext Ctx;
643 auto Buffer = loadFile(Filename);
644 auto Input = loadInputFile(Buffer->getMemBufferRef());
645 auto TheModule = loadModuleFromInput(*Input, Ctx);
646
647 ThinGenerator.promote(*TheModule, *Index, *Input);
623 auto TheModule = loadModule(Filename, Ctx);
624
625 ThinGenerator.promote(*TheModule, *Index);
648626
649627 std::string OutputName = OutputFilename;
650628 if (OutputName.empty()) {
673651
674652 for (auto &Filename : InputFilenames) {
675653 LLVMContext Ctx;
676 auto Buffer = loadFile(Filename);
677 auto Input = loadInputFile(Buffer->getMemBufferRef());
678 auto TheModule = loadModuleFromInput(*Input, Ctx);
679
680 ThinGenerator.crossModuleImport(*TheModule, *Index, *Input);
654 auto TheModule = loadModule(Filename, Ctx);
655
656 ThinGenerator.crossModuleImport(*TheModule, *Index);
681657
682658 std::string OutputName = OutputFilename;
683659 if (OutputName.empty()) {
706682
707683 for (auto &Filename : InputFilenames) {
708684 LLVMContext Ctx;
709 auto Buffer = loadFile(Filename);
710 auto Input = loadInputFile(Buffer->getMemBufferRef());
711 auto TheModule = loadModuleFromInput(*Input, Ctx);
712
713 ThinGenerator.internalize(*TheModule, *Index, *Input);
685 auto TheModule = loadModule(Filename, Ctx);
686
687 ThinGenerator.internalize(*TheModule, *Index);
714688
715689 std::string OutputName = OutputFilename;
716690 if (OutputName.empty()) {
731705
732706 for (auto &Filename : InputFilenames) {
733707 LLVMContext Ctx;
734 auto Buffer = loadFile(Filename);
735 auto Input = loadInputFile(Buffer->getMemBufferRef());
736 auto TheModule = loadModuleFromInput(*Input, Ctx);
708 auto TheModule = loadModule(Filename, Ctx);
737709
738710 ThinGenerator.optimize(*TheModule);
739711