llvm.org GIT mirror llvm / 95d9f1b
Apply summary-based dead stripping to regular LTO modules with summaries. If a regular LTO module has a summary index, then instead of linking it into the combined regular LTO module right away, add it to the combined summary index and associate it with a special module that represents the combined regular LTO module. Any such modules are linked during LTO::run(), at which time we use the results of summary-based dead stripping to control whether to link prevailing symbols. Differential Revision: https://reviews.llvm.org/D33922 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305482 91177308-0d34-0410-b5e6-96231b3b80d8 Peter Collingbourne 3 years ago
9 changed file(s) with 247 addition(s) and 112 deletion(s). Raw diff Collapse all Expand all
4141
4242 struct BitcodeFileContents;
4343
44 /// Basic information extracted from a bitcode module to be used for LTO.
45 struct BitcodeLTOInfo {
46 bool IsThinLTO;
47 bool HasSummary;
48 };
49
4450 /// Represents a module in a bitcode file.
4551 class BitcodeModule {
4652 // This covers the identification (if present) and module blocks.
8995 /// Read the entire bitcode module and return it.
9096 Expected> parseModule(LLVMContext &Context);
9197
92 /// Check if the given bitcode buffer contains a summary block.
93 Expected hasSummary();
98 /// Returns information about the module to be used for LTO: whether to
99 /// compile with ThinLTO, and whether it has a summary.
100 Expected getLTOInfo();
94101
95102 /// Parse the specified bitcode buffer, returning the module summary index.
96103 Expected> getSummary();
97104
98105 /// Parse the specified bitcode buffer and merge its module summary index
99106 /// into CombinedIndex.
100 Error readSummary(ModuleSummaryIndex &CombinedIndex, unsigned ModuleId);
107 Error readSummary(ModuleSummaryIndex &CombinedIndex, StringRef ModulePath,
108 uint64_t ModuleId);
101109 };
102110
103111 struct BitcodeFileContents {
146154 Expected> parseBitcodeFile(MemoryBufferRef Buffer,
147155 LLVMContext &Context);
148156
149 /// Check if the given bitcode buffer contains a summary block.
150 Expected hasGlobalValueSummary(MemoryBufferRef Buffer);
157 /// Returns LTO information for the specified bitcode file.
158 Expected getBitcodeLTOInfo(MemoryBufferRef Buffer);
151159
152160 /// Parse the specified bitcode buffer, returning the module summary index.
153161 Expected>
156164 /// Parse the specified bitcode buffer and merge the index into CombinedIndex.
157165 Error readModuleSummaryIndex(MemoryBufferRef Buffer,
158166 ModuleSummaryIndex &CombinedIndex,
159 unsigned ModuleId);
167 uint64_t ModuleId);
160168
161169 /// Parse the module summary index out of an IR file and return the module
162170 /// summary index object if found, or an empty summary if not. If Path refers
566566 bool isGlobalValueLive(const GlobalValueSummary *GVS) const {
567567 return !WithGlobalValueDeadStripping || GVS->isLive();
568568 }
569 bool isGUIDLive(GlobalValue::GUID GUID) const;
569570
570571 /// Return a ValueInfo for GUID if it exists, otherwise return ValueInfo().
571572 ValueInfo getValueInfo(GlobalValue::GUID GUID) const {
280280 bool HasModule = false;
281281 std::unique_ptr CombinedModule;
282282 std::unique_ptr Mover;
283
284 // This stores the information about a regular LTO module that we have added
285 // to the link. It will either be linked immediately (for modules without
286 // summaries) or after summary-based dead stripping (for modules with
287 // summaries).
288 struct AddedModule {
289 std::unique_ptr M;
290 std::vector Keep;
291 };
292 std::vector ModsWithSummaries;
283293 } RegularLTO;
284294
285295 struct ThinLTOState {
302312 /// The unmangled name of the global.
303313 std::string IRName;
304314
305 /// Keep track if the symbol is visible outside of ThinLTO (i.e. in
306 /// either a regular object or the regular LTO partition).
307 bool VisibleOutsideThinLTO = false;
315 /// Keep track if the symbol is visible outside of a module with a summary
316 /// (i.e. in either a regular object or a regular LTO module without a
317 /// summary).
318 bool VisibleOutsideSummary = false;
308319
309320 bool UnnamedAddr = true;
310321
338349 // Global mapping from mangled symbol names to resolutions.
339350 StringMap GlobalResolutions;
340351
341 void addSymbolToGlobalRes(const InputFile::Symbol &Sym, SymbolResolution Res,
342 unsigned Partition);
352 void addModuleToGlobalRes(ArrayRef Syms,
353 ArrayRef Res, unsigned Partition,
354 bool InSummary);
343355
344356 // These functions take a range of symbol resolutions [ResI, ResE) and consume
345357 // the resolutions used by a single input module by incrementing ResI. After
347359 // the remaining modules in the InputFile.
348360 Error addModule(InputFile &Input, unsigned ModI,
349361 const SymbolResolution *&ResI, const SymbolResolution *ResE);
350 Error addRegularLTO(BitcodeModule BM,
351 ArrayRef Syms,
352 const SymbolResolution *&ResI,
353 const SymbolResolution *ResE);
362
363 Expected
364 addRegularLTO(BitcodeModule BM, ArrayRef Syms,
365 const SymbolResolution *&ResI, const SymbolResolution *ResE);
366 Error linkRegularLTO(RegularLTOState::AddedModule Mod,
367 bool LivenessFromIndex);
368
354369 Error addThinLTO(BitcodeModule BM, ArrayRef Syms,
355370 const SymbolResolution *&ResI, const SymbolResolution *ResE);
356371
732732 std::vector makeCallList(ArrayRef Record,
733733 bool IsOldProfileFormat,
734734 bool HasProfile);
735 Error parseEntireSummary();
735 Error parseEntireSummary(unsigned ID);
736736 Error parseModuleStringTable();
737737
738738 std::pair
48534853 return error("Invalid record");
48544854 break;
48554855 case bitc::GLOBALVAL_SUMMARY_BLOCK_ID:
4856 case bitc::FULL_LTO_GLOBALVAL_SUMMARY_BLOCK_ID:
48564857 assert(!SeenValueSymbolTable &&
48574858 "Already read VST when parsing summary block?");
48584859 // We might not have a VST if there were no values in the
48654866 SeenValueSymbolTable = true;
48664867 }
48674868 SeenGlobalValSummary = true;
4868 if (Error Err = parseEntireSummary())
4869 if (Error Err = parseEntireSummary(Entry.ID))
48694870 return Err;
48704871 break;
48714872 case bitc::MODULE_STRTAB_BLOCK_ID:
49734974
49744975 // Eagerly parse the entire summary block. This populates the GlobalValueSummary
49754976 // objects in the index.
4976 Error ModuleSummaryIndexBitcodeReader::parseEntireSummary() {
4977 if (Stream.EnterSubBlock(bitc::GLOBALVAL_SUMMARY_BLOCK_ID))
4977 Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) {
4978 if (Stream.EnterSubBlock(ID))
49784979 return error("Invalid record");
49794980 SmallVector Record;
49804981
55165517 }
55175518
55185519 // Parse the specified bitcode buffer and merge the index into CombinedIndex.
5520 // We don't use ModuleIdentifier here because the client may need to control the
5521 // module path used in the combined summary (e.g. when reading summaries for
5522 // regular LTO modules).
55195523 Error BitcodeModule::readSummary(ModuleSummaryIndex &CombinedIndex,
5520 unsigned ModuleId) {
5524 StringRef ModulePath, uint64_t ModuleId) {
55215525 BitstreamCursor Stream(Buffer);
55225526 Stream.JumpToBit(ModuleBit);
55235527
55245528 ModuleSummaryIndexBitcodeReader R(std::move(Stream), Strtab, CombinedIndex,
5525 ModuleIdentifier, ModuleId);
5529 ModulePath, ModuleId);
55265530 return R.parseModule();
55275531 }
55285532
55425546 }
55435547
55445548 // Check if the given bitcode buffer contains a global value summary block.
5545 Expected<bool> BitcodeModule::hasSummary() {
5549 Expected<BitcodeLTOInfo> BitcodeModule::getLTOInfo() {
55465550 BitstreamCursor Stream(Buffer);
55475551 Stream.JumpToBit(ModuleBit);
55485552
55565560 case BitstreamEntry::Error:
55575561 return error("Malformed block");
55585562 case BitstreamEntry::EndBlock:
5559 return false;
5563 return BitcodeLTOInfo{/*IsThinLTO=*/false, /*HasSummary=*/false};
55605564
55615565 case BitstreamEntry::SubBlock:
55625566 if (Entry.ID == bitc::GLOBALVAL_SUMMARY_BLOCK_ID)
5563 return true;
5567 return BitcodeLTOInfo{/*IsThinLTO=*/true, /*HasSummary=*/true};
5568
5569 if (Entry.ID == bitc::FULL_LTO_GLOBALVAL_SUMMARY_BLOCK_ID)
5570 return BitcodeLTOInfo{/*IsThinLTO=*/false, /*HasSummary=*/true};
55645571
55655572 // Ignore other sub-blocks.
55665573 if (Stream.SkipBlock())
56475654
56485655 Error llvm::readModuleSummaryIndex(MemoryBufferRef Buffer,
56495656 ModuleSummaryIndex &CombinedIndex,
5650 unsigned ModuleId) {
5657 uint64_t ModuleId) {
56515658 Expected BM = getSingleModule(Buffer);
56525659 if (!BM)
56535660 return BM.takeError();
56545661
5655 return BM->readSummary(CombinedIndex, ModuleId);
5662 return BM->readSummary(CombinedIndex, BM->getModuleIdentifier(), ModuleId);
56565663 }
56575664
56585665 Expected>
56645671 return BM->getSummary();
56655672 }
56665673
5667 Expected<bool> llvm::hasGlobalValueSummary(MemoryBufferRef Buffer) {
5674 Expected<BitcodeLTOInfo> llvm::getBitcodeLTOInfo(MemoryBufferRef Buffer) {
56685675 Expected BM = getSingleModule(Buffer);
56695676 if (!BM)
56705677 return BM.takeError();
56715678
5672 return BM->hasSummary();
5679 return BM->getLTOInfo();
56735680 }
56745681
56755682 Expected>
5555 auto &Summary = VI.getSummaryList()[0];
5656 return Summary.get();
5757 }
58
59 bool ModuleSummaryIndex::isGUIDLive(GlobalValue::GUID GUID) const {
60 auto VI = getValueInfo(GUID);
61 if (!VI)
62 return false;
63 for (auto &I : VI.getSummaryList())
64 if (isGlobalValueLive(I.get()))
65 return true;
66 return false;
67 }
363363 // Requires a destructor for MapVector.
364364 LTO::~LTO() = default;
365365
366 // Add the given symbol to the GlobalResolutions map, and resolve its partition.
367 void LTO::addSymbolToGlobalRes(const InputFile::Symbol &Sym,
368 SymbolResolution Res, unsigned Partition) {
369 auto &GlobalRes = GlobalResolutions[Sym.getName()];
370 GlobalRes.UnnamedAddr &= Sym.isUnnamedAddr();
371 if (Res.Prevailing)
372 GlobalRes.IRName = Sym.getIRName();
373
374 // Set the partition to external if we know it is re-defined by the linker
375 // with -defsym or -wrap options, used elsewhere, e.g. it is visible to a
376 // regular object, is referenced from llvm.compiler_used, or was already
377 // recorded as being referenced from a different partition.
378 if (Res.LinkerRedefined || Res.VisibleToRegularObj || Sym.isUsed() ||
379 (GlobalRes.Partition != GlobalResolution::Unknown &&
380 GlobalRes.Partition != Partition)) {
381 GlobalRes.Partition = GlobalResolution::External;
382 } else
383 // First recorded reference, save the current partition.
384 GlobalRes.Partition = Partition;
385
386 // Flag as visible outside of ThinLTO if visible from a regular object or
387 // if this is a reference in the regular LTO partition.
388 GlobalRes.VisibleOutsideThinLTO |=
389 (Res.VisibleToRegularObj || Sym.isUsed() ||
390 Partition == GlobalResolution::RegularLTO);
366 // Add the symbols in the given module to the GlobalResolutions map, and resolve
367 // their partitions.
368 void LTO::addModuleToGlobalRes(ArrayRef Syms,
369 ArrayRef Res,
370 unsigned Partition, bool InSummary) {
371 auto *ResI = Res.begin();
372 auto *ResE = Res.end();
373 for (const InputFile::Symbol &Sym : Syms) {
374 assert(ResI != ResE);
375 SymbolResolution Res = *ResI++;
376
377 auto &GlobalRes = GlobalResolutions[Sym.getName()];
378 GlobalRes.UnnamedAddr &= Sym.isUnnamedAddr();
379 if (Res.Prevailing)
380 GlobalRes.IRName = Sym.getIRName();
381
382 // Set the partition to external if we know it is re-defined by the linker
383 // with -defsym or -wrap options, used elsewhere, e.g. it is visible to a
384 // regular object, is referenced from llvm.compiler_used, or was already
385 // recorded as being referenced from a different partition.
386 if (Res.LinkerRedefined || Res.VisibleToRegularObj || Sym.isUsed() ||
387 (GlobalRes.Partition != GlobalResolution::Unknown &&
388 GlobalRes.Partition != Partition)) {
389 GlobalRes.Partition = GlobalResolution::External;
390 } else
391 // First recorded reference, save the current partition.
392 GlobalRes.Partition = Partition;
393
394 // Flag as visible outside of summary if visible from a regular object or
395 // from a module that does not have a summary.
396 GlobalRes.VisibleOutsideSummary |=
397 (Res.VisibleToRegularObj || Sym.isUsed() || !InSummary);
398 }
391399 }
392400
393401 static void writeToResolutionFile(raw_ostream &OS, InputFile *Input,
433441 Error LTO::addModule(InputFile &Input, unsigned ModI,
434442 const SymbolResolution *&ResI,
435443 const SymbolResolution *ResE) {
436 Expected HasThinLTOSummary = Input.Mods[ModI].hasSummary();
437 if (!HasThinLTOSummary)
438 return HasThinLTOSummary.takeError();
439
444 Expected LTOInfo = Input.Mods[ModI].getLTOInfo();
445 if (!LTOInfo)
446 return LTOInfo.takeError();
447
448 BitcodeModule BM = Input.Mods[ModI];
440449 auto ModSyms = Input.module_symbols(ModI);
441 if (*HasThinLTOSummary)
442 return addThinLTO(Input.Mods[ModI], ModSyms, ResI, ResE);
443 else
444 return addRegularLTO(Input.Mods[ModI], ModSyms, ResI, ResE);
450 addModuleToGlobalRes(ModSyms, {ResI, ResE},
451 LTOInfo->IsThinLTO ? ThinLTO.ModuleMap.size() + 1 : 0,
452 LTOInfo->HasSummary);
453
454 if (LTOInfo->IsThinLTO)
455 return addThinLTO(BM, ModSyms, ResI, ResE);
456
457 Expected ModOrErr =
458 addRegularLTO(BM, ModSyms, ResI, ResE);
459 if (!ModOrErr)
460 return ModOrErr.takeError();
461
462 if (!LTOInfo->HasSummary)
463 return linkRegularLTO(std::move(*ModOrErr), /*LivenessFromIndex=*/false);
464
465 // Regular LTO module summaries are added to a dummy module that represents
466 // the combined regular LTO module.
467 if (Error Err = BM.readSummary(ThinLTO.CombinedIndex, "", -1ull))
468 return Err;
469 RegularLTO.ModsWithSummaries.push_back(std::move(*ModOrErr));
470 return Error::success();
445471 }
446472
447473 // Add a regular LTO object to the link.
448 Error LTO::addRegularLTO(BitcodeModule BM,
449 ArrayRef Syms,
450 const SymbolResolution *&ResI,
451 const SymbolResolution *ResE) {
452 if (!RegularLTO.CombinedModule) {
453 RegularLTO.CombinedModule =
454 llvm::make_unique("ld-temp.o", RegularLTO.Ctx);
455 RegularLTO.Mover = llvm::make_unique(*RegularLTO.CombinedModule);
456 }
474 // The resulting module needs to be linked into the combined LTO module with
475 // linkRegularLTO.
476 Expected
477 LTO::addRegularLTO(BitcodeModule BM, ArrayRef Syms,
478 const SymbolResolution *&ResI,
479 const SymbolResolution *ResE) {
480 RegularLTOState::AddedModule Mod;
457481 Expected> MOrErr =
458482 BM.getLazyModule(RegularLTO.Ctx, /*ShouldLazyLoadMetadata*/ true,
459483 /*IsImporting*/ false);
460484 if (!MOrErr)
461485 return MOrErr.takeError();
462
463486 Module &M = **MOrErr;
487 Mod.M = std::move(*MOrErr);
488
464489 if (Error Err = M.materializeMetadata())
465 return Err;
490 return std::move(Err);
466491 UpgradeDebugInfo(M);
467492
468493 ModuleSymbolTable SymTab;
469494 SymTab.addModule(&M);
470495
471 std::vector Keep;
472
473496 for (GlobalVariable &GV : M.globals())
474497 if (GV.hasAppendingLinkage())
475 Keep.push_back(&GV);
498 Mod.Keep.push_back(&GV);
476499
477500 DenseSet AliasedGlobals;
478501 for (auto &GA : M.aliases())
501524 for (const InputFile::Symbol &Sym : Syms) {
502525 assert(ResI != ResE);
503526 SymbolResolution Res = *ResI++;
504 addSymbolToGlobalRes(Sym, Res, 0);
505527
506528 assert(MsymI != MsymE);
507529 ModuleSymbolTable::Symbol Msym = *MsymI++;
511533 if (Res.Prevailing) {
512534 if (Sym.isUndefined())
513535 continue;
514 Keep.push_back(GV);
536 Mod.Keep.push_back(GV);
515537 // For symbols re-defined with linker -wrap and -defsym options,
516538 // set the linkage to weak to inhibit IPO. The linkage will be
517539 // restored by the linker.
526548 (GV->hasLinkOnceODRLinkage() || GV->hasWeakODRLinkage() ||
527549 GV->hasAvailableExternallyLinkage()) &&
528550 !AliasedGlobals.count(cast(GV))) {
529 // Either of the above three types of linkage indicates that the
551 // Any of the above three types of linkage indicates that the
530552 // chosen prevailing symbol will have the same semantics as this copy of
531 // the symbol, so we can link it with available_externally linkage. We
532 // only need to do this if the symbol is undefined.
533 GlobalValue *CombinedGV =
534 RegularLTO.CombinedModule->getNamedValue(GV->getName());
535 if (!CombinedGV || CombinedGV->isDeclaration()) {
536 Keep.push_back(GV);
537 GV->setLinkage(GlobalValue::AvailableExternallyLinkage);
538 cast(GV)->setComdat(nullptr);
539 }
553 // the symbol, so we may be able to link it with available_externally
554 // linkage. We will decide later whether to do that when we link this
555 // module (in linkRegularLTO), based on whether it is undefined.
556 Mod.Keep.push_back(GV);
557 GV->setLinkage(GlobalValue::AvailableExternallyLinkage);
558 cast(GV)->setComdat(nullptr);
540559 }
541560 }
542561 // Common resolution: collect the maximum size/alignment over all commons.
554573 // FIXME: use proposed local attribute for FinalDefinitionInLinkageUnit.
555574 }
556575 assert(MsymI == MsymE);
557
558 return RegularLTO.Mover->move(std::move(*MOrErr), Keep,
576 return std::move(Mod);
577 }
578
579 Error LTO::linkRegularLTO(RegularLTOState::AddedModule Mod,
580 bool LivenessFromIndex) {
581 if (!RegularLTO.CombinedModule) {
582 RegularLTO.CombinedModule =
583 llvm::make_unique("ld-temp.o", RegularLTO.Ctx);
584 RegularLTO.Mover = llvm::make_unique(*RegularLTO.CombinedModule);
585 }
586
587 std::vector Keep;
588 for (GlobalValue *GV : Mod.Keep) {
589 if (LivenessFromIndex && !ThinLTO.CombinedIndex.isGUIDLive(GV->getGUID()))
590 continue;
591
592 if (!GV->hasAvailableExternallyLinkage()) {
593 Keep.push_back(GV);
594 continue;
595 }
596
597 // Only link available_externally definitions if we don't already have a
598 // definition.
599 GlobalValue *CombinedGV =
600 RegularLTO.CombinedModule->getNamedValue(GV->getName());
601 if (CombinedGV && !CombinedGV->isDeclaration())
602 continue;
603
604 Keep.push_back(GV);
605 }
606
607 return RegularLTO.Mover->move(std::move(Mod.M), Keep,
559608 [](GlobalValue &, IRMover::ValueAdder) {},
560609 /* IsPerformingImport */ false);
561610 }
562611
563 // Add a ThinLTO object to the link.
564 Error LTO::addThinLTO(BitcodeModule BM,
565 ArrayRef Syms,
612 // Add a ThinLTO module to the link.
613 Error LTO::addThinLTO(BitcodeModule BM, ArrayRef Syms,
566614 const SymbolResolution *&ResI,
567615 const SymbolResolution *ResE) {
568616 if (Error Err =
569 BM.readSummary(ThinLTO.CombinedIndex, ThinLTO.ModuleMap.size()))
617 BM.readSummary(ThinLTO.CombinedIndex, BM.getModuleIdentifier(),
618 ThinLTO.ModuleMap.size()))
570619 return Err;
571620
572621 for (const InputFile::Symbol &Sym : Syms) {
573622 assert(ResI != ResE);
574623 SymbolResolution Res = *ResI++;
575 addSymbolToGlobalRes(Sym, Res, ThinLTO.ModuleMap.size() + 1);
576624
577625 if (Res.Prevailing) {
578626 if (!Sym.getIRName().empty()) {
600648 // Compute "dead" symbols, we don't want to import/export these!
601649 DenseSet GUIDPreservedSymbols;
602650 for (auto &Res : GlobalResolutions) {
603 if (Res.second.VisibleOutsideThinLTO &&
651 if (Res.second.VisibleOutsideSummary &&
604652 // IRName will be defined if we have seen the prevailing copy of
605653 // this value. If not, no need to preserve any ThinLTO copies.
606654 !Res.second.IRName.empty())
613661 // Save the status of having a regularLTO combined module, as
614662 // this is needed for generating the ThinLTO Task ID, and
615663 // the CombinedModule will be moved at the end of runRegularLTO.
616 bool HasRegularLTO = RegularLTO.CombinedModule != nullptr;
664 bool HasRegularLTO = RegularLTO.CombinedModule != nullptr ||
665 !RegularLTO.ModsWithSummaries.empty();
617666 // Invoke regular LTO if there was a regular LTO module to start with.
618667 if (HasRegularLTO)
619668 if (auto E = runRegularLTO(AddStream))
622671 }
623672
624673 Error LTO::runRegularLTO(AddStreamFn AddStream) {
674 for (auto &M : RegularLTO.ModsWithSummaries)
675 if (Error Err = linkRegularLTO(std::move(M),
676 /*LivenessFromIndex=*/true))
677 return Err;
678
625679 // Make sure commons have the right size/alignment: we kept the largest from
626680 // all the prevailing when adding the inputs, and we apply it here.
627681 const DataLayout &DL = RegularLTO.CombinedModule->getDataLayout();
919973 };
920974 }
921975
922 static bool IsLiveByGUID(const ModuleSummaryIndex &Index,
923 GlobalValue::GUID GUID) {
924 auto VI = Index.getValueInfo(GUID);
925 if (!VI)
926 return false;
927 for (auto &I : VI.getSummaryList())
928 if (Index.isGlobalValueLive(I.get()))
929 return true;
930 return false;
931 }
932
933976 Error LTO::runThinLTO(AddStreamFn AddStream, NativeObjectCache Cache,
934977 bool HasRegularLTO) {
935978 if (ThinLTO.ModuleMap.empty())
9781021 auto GUID = GlobalValue::getGUID(
9791022 GlobalValue::dropLLVMManglingEscape(Res.second.IRName));
9801023 // Mark exported unless index-based analysis determined it to be dead.
981 if (IsLiveByGUID(ThinLTO.CombinedIndex, GUID))
1024 if (ThinLTO.CombinedIndex.isGUIDLive(GUID))
9821025 ExportedGUIDs.insert(GUID);
9831026 }
9841027
7676 }
7777
7878 bool LTOModule::isThinLTO() {
79 // Right now the detection is only based on the summary presence. We may want
80 // to add a dedicated flag at some point.
81 Expected<bool> Result = hasGlobalValueSummary(MBRef);
79 Expected<BitcodeLTOInfo> Result = getBitcodeLTOInfo(MBRef);
8280 if (!Result) {
8381 logAllUnhandledErrors(Result.takeError(), errs(), "");
8482 return false;
8583 }
86 return *Result;
84 return Result->IsThinLTO;
8785 }
8886
8987 bool LTOModule::isBitcodeForTarget(MemoryBuffer *Buffer,
0 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
1 target triple = "x86_64-unknown-linux-gnu"
2
3 define void @live1() {
4 call void @live2()
5 ret void
6 }
7
8 declare void @live2()
9
10 define void @dead1() {
11 call void @dead2()
12 ret void
13 }
14
15 declare void @dead2()
0 ; RUN: opt -module-summary -o %t %s
1 ; RUN: opt -module-summary -o %t2 %S/Inputs/dead-strip-fulllto.ll
2 ; RUN: llvm-lto2 run %t -r %t,main,px -r %t,live1,p -r %t,live2,p -r %t,dead2,p \
3 ; RUN: %t2 -r %t2,live1,p -r %t2,live2, -r %t2,dead1,p -r %t2,dead2, \
4 ; RUN: -save-temps -o %t3
5 ; RUN: llvm-nm %t3.0 | FileCheck --check-prefix=FULL %s
6 ; RUN: llvm-nm %t3.1 | FileCheck --check-prefix=THIN %s
7
8 ; FULL-NOT: dead
9 ; FULL: U live1
10 ; FULL: T live2
11 ; FULL: T main
12
13 ; THIN-NOT: dead
14 ; THIN: T live1
15 ; THIN: U live2
16
17 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
18 target triple = "x86_64-unknown-linux-gnu"
19
20 define void @main() {
21 call void @live1()
22 ret void
23 }
24
25 declare void @live1()
26
27 define void @live2() {
28 ret void
29 }
30
31 define void @dead2() {
32 ret void
33 }
34
35 !0 = !{i32 1, !"ThinLTO", i32 0}
36 !llvm.module.flags = !{ !0 }