llvm.org GIT mirror llvm / e393775
[LTO] Record whether LTOUnit splitting is enabled in index Summary: Records in the module summary index whether the bitcode was compiled with the option necessary to enable splitting the LTO unit (e.g. -fsanitize=cfi, -fwhole-program-vtables, or -fsplit-lto-unit). The information is passed down to the ModuleSummaryIndex builder via a new module flag "EnableSplitLTOUnit", which is propagated onto a flag on the summary index. This is then used during the LTO link to check whether all linked summaries were built with the same value of this flag. If not, an error is issued when we detect a situation requiring whole program visibility of the class hierarchy. This is the case when both of the following conditions are met: 1) We are performing LowerTypeTests or Whole Program Devirtualization. 2) There are type tests or type checked loads in the code. Note I have also changed the ThinLTOBitcodeWriter to also gate the module splitting on the value of this flag. Reviewers: pcc Subscribers: ormris, mehdi_amini, Prazek, inglorion, eraman, steven_wu, dexonsmith, arphaman, dang, llvm-commits Differential Revision: https://reviews.llvm.org/D53890 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350948 91177308-0d34-0410-b5e6-96231b3b80d8 Teresa Johnson 7 months ago
44 changed file(s) with 268 addition(s) and 39 deletion(s). Raw diff Collapse all Expand all
5050 struct BitcodeLTOInfo {
5151 bool IsThinLTO;
5252 bool HasSummary;
53 bool EnableSplitLTOUnit;
5354 };
5455
5556 /// Represents a module in a bitcode file.
830830 /// union.
831831 bool HaveGVs;
832832
833 // True if the index was created for a module compiled with -fsplit-lto-unit.
834 bool EnableSplitLTOUnit;
835
836 // True if some of the modules were compiled with -fsplit-lto-unit and
837 // some were not. Set when the combined index is created during the thin link.
838 bool PartiallySplitLTOUnits = false;
839
833840 std::set CfiFunctionDefs;
834841 std::set CfiFunctionDecls;
835842
849856
850857 public:
851858 // See HaveGVs variable comment.
852 ModuleSummaryIndex(bool HaveGVs) : HaveGVs(HaveGVs), Saver(Alloc) {}
859 ModuleSummaryIndex(bool HaveGVs, bool EnableSplitLTOUnit = false)
860 : HaveGVs(HaveGVs), EnableSplitLTOUnit(EnableSplitLTOUnit), Saver(Alloc) {
861 }
853862
854863 bool haveGVs() const { return HaveGVs; }
855864
938947 void setSkipModuleByDistributedBackend() {
939948 SkipModuleByDistributedBackend = true;
940949 }
950
951 bool enableSplitLTOUnit() const { return EnableSplitLTOUnit; }
952 void setEnableSplitLTOUnit() { EnableSplitLTOUnit = true; }
953
954 bool partiallySplitLTOUnits() const { return PartiallySplitLTOUnits; }
955 void setPartiallySplitLTOUnits() { PartiallySplitLTOUnits = true; }
941956
942957 bool isGlobalValueLive(const GlobalValueSummary *GVS) const {
943958 return !WithGlobalValueDeadStripping || GVS->isLive();
399399 Error runThinLTO(AddStreamFn AddStream, NativeObjectCache Cache);
400400
401401 mutable bool CalledGetMaxTasks = false;
402
403 // Use Optional to distinguish false from not yet initialized.
404 Optional EnableSplitLTOUnit;
402405 };
403406
404407 /// The resolution for a symbol. The linker must provide a SymbolResolution for
456456 std::function GetBFICallback,
457457 ProfileSummaryInfo *PSI) {
458458 assert(PSI);
459 ModuleSummaryIndex Index(/*HaveGVs=*/true);
459 bool EnableSplitLTOUnit = false;
460 if (auto *MD = mdconst::extract_or_null(
461 M.getModuleFlag("EnableSplitLTOUnit")))
462 EnableSplitLTOUnit = MD->getZExtValue();
463 ModuleSummaryIndex Index(/*HaveGVs=*/true, EnableSplitLTOUnit);
460464
461465 // Identify the local values in the llvm.used and llvm.compiler.used sets,
462466 // which should not be exported as they would then require renaming and
52935293 break;
52945294 case bitc::FS_FLAGS: { // [flags]
52955295 uint64_t Flags = Record[0];
5296 // Scan flags (set only on the combined index).
5297 assert(Flags <= 0x3 && "Unexpected bits in flag");
5296 // Scan flags.
5297 assert(Flags <= 0x1f && "Unexpected bits in flag");
52985298
52995299 // 1 bit: WithGlobalValueDeadStripping flag.
5300 // Set on combined index only.
53005301 if (Flags & 0x1)
53015302 TheIndex.setWithGlobalValueDeadStripping();
53025303 // 1 bit: SkipModuleByDistributedBackend flag.
5304 // Set on combined index only.
53035305 if (Flags & 0x2)
53045306 TheIndex.setSkipModuleByDistributedBackend();
53055307 // 1 bit: HasSyntheticEntryCounts flag.
5308 // Set on combined index only.
53065309 if (Flags & 0x4)
53075310 TheIndex.setHasSyntheticEntryCounts();
5311 // 1 bit: DisableSplitLTOUnit flag.
5312 // Set on per module indexes. It is up to the client to validate
5313 // the consistency of this flag across modules being linked.
5314 if (Flags & 0x8)
5315 TheIndex.setEnableSplitLTOUnit();
5316 // 1 bit: PartiallySplitLTOUnits flag.
5317 // Set on combined index only.
5318 if (Flags & 0x10)
5319 TheIndex.setPartiallySplitLTOUnits();
53085320 break;
53095321 }
53105322 case bitc::FS_VALUE_GUID: { // [valueid, refguid]
59165928 return std::move(Index);
59175929 }
59185930
5931 static Expected getEnableSplitLTOUnitFlag(BitstreamCursor &Stream,
5932 unsigned ID) {
5933 if (Stream.EnterSubBlock(ID))
5934 return error("Invalid record");
5935 SmallVector Record;
5936
5937 while (true) {
5938 BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
5939
5940 switch (Entry.Kind) {
5941 case BitstreamEntry::SubBlock: // Handled for us already.
5942 case BitstreamEntry::Error:
5943 return error("Malformed block");
5944 case BitstreamEntry::EndBlock:
5945 // If no flags record found, conservatively return true to mimic
5946 // behavior before this flag was added.
5947 return true;
5948 case BitstreamEntry::Record:
5949 // The interesting case.
5950 break;
5951 }
5952
5953 // Look for the FS_FLAGS record.
5954 Record.clear();
5955 auto BitCode = Stream.readRecord(Entry.ID, Record);
5956 switch (BitCode) {
5957 default: // Default behavior: ignore.
5958 break;
5959 case bitc::FS_FLAGS: { // [flags]
5960 uint64_t Flags = Record[0];
5961 // Scan flags.
5962 assert(Flags <= 0x1f && "Unexpected bits in flag");
5963
5964 return Flags & 0x8;
5965 }
5966 }
5967 }
5968 llvm_unreachable("Exit infinite loop");
5969 }
5970
59195971 // Check if the given bitcode buffer contains a global value summary block.
59205972 Expected BitcodeModule::getLTOInfo() {
59215973 BitstreamCursor Stream(Buffer);
59315983 case BitstreamEntry::Error:
59325984 return error("Malformed block");
59335985 case BitstreamEntry::EndBlock:
5934 return BitcodeLTOInfo{/*IsThinLTO=*/false, /*HasSummary=*/false};
5986 return BitcodeLTOInfo{/*IsThinLTO=*/false, /*HasSummary=*/false,
5987 /*EnableSplitLTOUnit=*/false};
59355988
59365989 case BitstreamEntry::SubBlock:
5937 if (Entry.ID == bitc::GLOBALVAL_SUMMARY_BLOCK_ID)
5938 return BitcodeLTOInfo{/*IsThinLTO=*/true, /*HasSummary=*/true};
5939
5940 if (Entry.ID == bitc::FULL_LTO_GLOBALVAL_SUMMARY_BLOCK_ID)
5941 return BitcodeLTOInfo{/*IsThinLTO=*/false, /*HasSummary=*/true};
5990 if (Entry.ID == bitc::GLOBALVAL_SUMMARY_BLOCK_ID) {
5991 Expected EnableSplitLTOUnit =
5992 getEnableSplitLTOUnitFlag(Stream, Entry.ID);
5993 if (!EnableSplitLTOUnit)
5994 return EnableSplitLTOUnit.takeError();
5995 return BitcodeLTOInfo{/*IsThinLTO=*/true, /*HasSummary=*/true,
5996 *EnableSplitLTOUnit};
5997 }
5998
5999 if (Entry.ID == bitc::FULL_LTO_GLOBALVAL_SUMMARY_BLOCK_ID) {
6000 Expected EnableSplitLTOUnit =
6001 getEnableSplitLTOUnitFlag(Stream, Entry.ID);
6002 if (!EnableSplitLTOUnit)
6003 return EnableSplitLTOUnit.takeError();
6004 return BitcodeLTOInfo{/*IsThinLTO=*/false, /*HasSummary=*/true,
6005 *EnableSplitLTOUnit};
6006 }
59426007
59436008 // Ignore other sub-blocks.
59446009 if (Stream.SkipBlock())
36173617
36183618 Stream.EmitRecord(bitc::FS_VERSION, ArrayRef{INDEX_VERSION});
36193619
3620 // Write the index flags.
3621 uint64_t Flags = 0;
3622 // Bits 1-3 are set only in the combined index, skip them.
3623 if (Index->enableSplitLTOUnit())
3624 Flags |= 0x8;
3625 Stream.EmitRecord(bitc::FS_FLAGS, ArrayRef{Flags});
3626
36203627 if (Index->begin() == Index->end()) {
36213628 Stream.ExitBlock();
36223629 return;
37333740 Flags |= 0x2;
37343741 if (Index.hasSyntheticEntryCounts())
37353742 Flags |= 0x4;
3743 if (Index.enableSplitLTOUnit())
3744 Flags |= 0x8;
3745 if (Index.partiallySplitLTOUnits())
3746 Flags |= 0x10;
37363747 Stream.EmitRecord(bitc::FS_FLAGS, ArrayRef{Flags});
37373748
37383749 for (const auto &GVI : valueIds()) {
545545 if (!LTOInfo)
546546 return LTOInfo.takeError();
547547
548 if (EnableSplitLTOUnit.hasValue()) {
549 // If only some modules were split, flag this in the index so that
550 // we can skip or error on optimizations that need consistently split
551 // modules (whole program devirt and lower type tests).
552 if (EnableSplitLTOUnit.getValue() != LTOInfo->EnableSplitLTOUnit)
553 ThinLTO.CombinedIndex.setPartiallySplitLTOUnits();
554 } else
555 EnableSplitLTOUnit = LTOInfo->EnableSplitLTOUnit;
556
548557 BitcodeModule BM = Input.Mods[ModI];
549558 auto ModSyms = Input.module_symbols(ModI);
550559 addModuleToGlobalRes(ModSyms, {ResI, ResE},
17011701 !ExportSummary && !ImportSummary)
17021702 return false;
17031703
1704 // If only some of the modules were split, we cannot correctly handle
1705 // code that contains type tests.
1706 if (TypeTestFunc && !TypeTestFunc->use_empty() &&
1707 ((ExportSummary && ExportSummary->partiallySplitLTOUnits()) ||
1708 (ImportSummary && ImportSummary->partiallySplitLTOUnits())))
1709 report_fatal_error("inconsistent LTO Unit splitting with llvm.type.test");
1710
17041711 if (ImportSummary) {
17051712 if (TypeTestFunc) {
17061713 for (auto UI = TypeTestFunc->use_begin(), UE = TypeTestFunc->use_end();
417417 }
418418 }
419419
420 // Returns whether this module needs to be split because it uses type metadata.
420 // Returns whether this module needs to be split because splitting is
421 // enabled and it uses type metadata.
421422 bool requiresSplit(Module &M) {
423 // First check if the LTO Unit splitting has been enabled.
424 bool EnableSplitLTOUnit = false;
425 if (auto *MD = mdconst::extract_or_null(
426 M.getModuleFlag("EnableSplitLTOUnit")))
427 EnableSplitLTOUnit = MD->getZExtValue();
428 if (!EnableSplitLTOUnit)
429 return false;
430
431 // Module only needs to be split if it contains type metadata.
422432 for (auto &GO : M.global_objects()) {
423433 if (GO.hasMetadata(LLVMContext::MD_type))
424434 return true;
430440 void writeThinLTOBitcode(raw_ostream &OS, raw_ostream *ThinLinkOS,
431441 function_ref AARGetter,
432442 Module &M, const ModuleSummaryIndex *Index) {
433 // See if this module has any type metadata. If so, we need to split it.
443 // Split module if splitting is enabled and it contains any type metadata.
434444 if (requiresSplit(M))
435445 return splitAndWriteThinLTOBitcode(OS, ThinLinkOS, AARGetter, M);
436446
15621562 M.getFunction(Intrinsic::getName(Intrinsic::type_checked_load));
15631563 Function *AssumeFunc = M.getFunction(Intrinsic::getName(Intrinsic::assume));
15641564
1565 // If only some of the modules were split, we cannot correctly handle
1566 // code that contains type tests or type checked loads.
1567 if ((ExportSummary && ExportSummary->partiallySplitLTOUnits()) ||
1568 (ImportSummary && ImportSummary->partiallySplitLTOUnits())) {
1569 if ((TypeTestFunc && !TypeTestFunc->use_empty()) ||
1570 (TypeCheckedLoadFunc && !TypeCheckedLoadFunc->use_empty()))
1571 report_fatal_error("inconsistent LTO Unit splitting with llvm.type.test "
1572 "or llvm.type.checked.load");
1573 return false;
1574 }
1575
15651576 // Normally if there are no users of the devirtualization intrinsics in the
15661577 // module, this pass has nothing to do. But if we are exporting, we also need
15671578 // to handle any users that appear only in the function summaries.
1717 ; CHECK-NEXT:
1818 ; CHECK:
1919 ; CHECK-NEXT:
20 ; CHECK-NEXT:
2021 ; See if the call to func is registered.
2122 ; The value id 1 matches the second FUNCTION record above.
2223 ; CHECK-NEXT:
33
44 ; CHECK:
55 ; CHECK-NEXT:
6 ; CHECK-NEXT:
67 ; CHECK-NEXT:
78 ; CHECK-NEXT:
89 ; CHECK-NEXT:
44
55 ; CHECK:
66 ; CHECK-NEXT:
7 ; CHECK-NEXT:
78 ; "op7" is a call to "callee" function.
89 ; CHECK-NEXT:
910 ; "another_caller" has only references but no calls.
1515 ; CHECK-NEXT:
1616 ; CHECK:
1717 ; CHECK-NEXT:
18 ; CHECK-NEXT:
1819 ; See if the call to func is registered, using the expected hotness type.
1920 ; CHECK-NEXT:
2021 ; CHECK-NEXT:
4545 ; CHECK-NEXT:
4646 ; CHECK-LABEL:
4747 ; CHECK-NEXT:
48 ; CHECK-NEXT:
4849 ; CHECK-NEXT:
4950 ; op4=hot1 op6=cold op8=hot2 op10=hot4 op12=none1 op14=hot3 op16=none2 op18=none3 op20=123
5051 ; CHECK-NEXT:
1111 ; CHECK-NEXT:
1212 ; CHECK:
1313 ; CHECK-NEXT:
14 ; CHECK-NEXT:
1415 ; See if the call to func is registered.
1516 ; CHECK-NEXT:
1617 ; CHECK-NEXT:
2828
2929 ; CHECK-LABEL:
3030 ; CHECK-NEXT:
31 ; CHECK-NEXT:
3132 ; CHECK-NEXT:
3233 ; op4=none1 op6=hot1 op8=cold1 op10=none2 op12=hot2 op14=cold2 op16=none3 op18=hot3 op20=cold3 op22=123
3334 ; CHECK-NEXT:
1616 ; CHECK-NEXT:
1717 ; CHECK:
1818 ; CHECK-NEXT:
19 ; CHECK-NEXT:
1920 ; See if the call to func is registered
2021 ; CHECK-NEXT:
2122 ; CHECK-NEXT:
1818 ; BC-NEXT:
1919 ; BC:
2020 ; BC-NEXT:
21 ; BC-NEXT:
2122 ; BC-NEXT:
2223 ; BC-NEXT:
2324 ; BC-NEXT:
11 ; the full LTO object file; any such functions will be referenced by the jump
22 ; table.
33
4 ; RUN: opt -thinlto-bc -o %t %s
4 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t %s
55 ; RUN: llvm-lto2 run -o %t2 -r %t,f1,p -r %t,f2,p -r %t,_start,px %t -save-temps
66 ; RUN: llvm-dis %t2.1.2.internalize.bc -o - | FileCheck %s
77
None ; RUN: opt -thinlto-bc -o %t0.bc %s
0 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t0.bc %s
11 ; RUN: llvm-lto2 run -r %t0.bc,__imp_f,l \
22 ; RUN: -r %t0.bc,g,p \
33 ; RUN: -r %t0.bc,g,l \
None ; RUN: opt -thinlto-bc -o %t %s
0 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t %s
11 ; RUN: llvm-lto2 run -r %t,f,plx -r %t,g_alias,plx -r %t,foo,lx -r %t,foo,plx -r %t,bar,lx -r %t,bar,plx -o %t1 %t
22 ; RUN: llvm-nm %t1.0 | FileCheck --check-prefix=MERGED %s
33 ; RUN: llvm-nm %t1.1 | FileCheck %s
0 ; Test to ensure that the Enable Split LTO Unit flag is set properly in the
1 ; summary, and that we correctly silently handle linking bitcode files with
2 ; different values of this flag.
3
4 ; Linking bitcode both with EnableSplitLTOUnit set should work
5 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t1 %s
6 ; RUN: llvm-bcanalyzer -dump %t1 | FileCheck %s --check-prefix=SPLITLTOUNIT
7 ; RUN: llvm-dis -o - %t1 | FileCheck %s --check-prefix=ENABLESPLITFLAG
8 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t2 %s
9 ; RUN: llvm-bcanalyzer -dump %t2 | FileCheck %s --check-prefix=SPLITLTOUNIT
10 ; RUN: llvm-dis -o - %t2 | FileCheck %s --check-prefix=ENABLESPLITFLAG
11 ; RUN: llvm-lto2 run -o %t3 %t1 %t2
12
13 ; Linking bitcode both without EnableSplitLTOUnit set should work
14 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit=false -o %t1 %s
15 ; RUN: llvm-bcanalyzer -dump %t1 | FileCheck %s --check-prefix=NOSPLITLTOUNIT
16 ; RUN: llvm-dis -o - %t1 | FileCheck %s --check-prefix=NOENABLESPLITFLAG
17 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit=false -o %t2 %s
18 ; RUN: llvm-bcanalyzer -dump %t2 | FileCheck %s --check-prefix=NOSPLITLTOUNIT
19 ; RUN: llvm-dis -o - %t2 | FileCheck %s --check-prefix=NOENABLESPLITFLAG
20 ; RUN: llvm-lto2 run -o %t3 %t1 %t2
21
22 ; Linking bitcode with different values of EnableSplitLTOUnit should succeed
23 ; (silently skipping any optimizations like whole program devirt that rely
24 ; on all modules being split).
25 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t1 %s
26 ; RUN: llvm-bcanalyzer -dump %t1 | FileCheck %s --check-prefix=SPLITLTOUNIT
27 ; RUN: llvm-dis -o - %t1 | FileCheck %s --check-prefix=ENABLESPLITFLAG
28 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit=false -o %t2 %s
29 ; RUN: llvm-bcanalyzer -dump %t2 | FileCheck %s --check-prefix=NOSPLITLTOUNIT
30 ; RUN: llvm-dis -o - %t2 | FileCheck %s --check-prefix=NOENABLESPLITFLAG
31 ; RUN: llvm-lto2 run -o %t3 %t1 %t2
32
33 ; Linking bitcode with different values of EnableSplitLTOUnit (reverse order)
34 ; should succeed (silently skipping any optimizations like whole program devirt
35 ; that rely on all modules being split).
36 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit=false -o %t1 %s
37 ; RUN: llvm-bcanalyzer -dump %t1 | FileCheck %s --check-prefix=NOSPLITLTOUNIT
38 ; RUN: llvm-dis -o - %t1 | FileCheck %s --check-prefix=NOENABLESPLITFLAG
39 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t2 %s
40 ; RUN: llvm-bcanalyzer -dump %t2 | FileCheck %s --check-prefix=SPLITLTOUNIT
41 ; RUN: llvm-dis -o - %t2 | FileCheck %s --check-prefix=ENABLESPLITFLAG
42 ; RUN: llvm-lto2 run -o %t3 %t1 %t2
43
44 ; The flag should be set when splitting is disabled (for backwards compatibility
45 ; with older bitcode where it was always enabled).
46 ; SPLITLTOUNIT:
47 ; NOSPLITLTOUNIT:
48
49 ; Check that the corresponding module flag is set when expected.
50 ; ENABLESPLITFLAG: !{i32 1, !"EnableSplitLTOUnit", i32 1}
51 ; NOENABLESPLITFLAG-NOT: !{i32 1, !"EnableSplitLTOUnit", i32 1}
52
53 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
54 target triple = "x86_64-unknown-linux-gnu"
33 ; This affects code generated for any users of f(). Make sure that we don't pull a stale object
44 ; file for %t.o from the cache.
55
6 ; RUN: opt -module-hash -module-summary -thinlto-bc %s -o %t.bc
7 ; RUN: opt -module-hash -module-summary -thinlto-bc %p/Inputs/cache-icall.ll -o %t2.bc
6 ; RUN: opt -module-hash -module-summary -thinlto-bc -thinlto-split-lto-unit %s -o %t.bc
7 ; RUN: opt -module-hash -module-summary -thinlto-bc -thinlto-split-lto-unit %p/Inputs/cache-icall.ll -o %t2.bc
88
99 ; RUN: rm -Rf %t.cache && mkdir %t.cache
1010
11
22 ; Test CFI devirtualization through the thin link and backend.
33
4 ; RUN: opt -thinlto-bc -o %t.o %s
4 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t.o %s
55
66 ; Legacy PM
77 ; FIXME: Fix machine verifier issues and remove -verify-machineinstrs=0. PR39436.
4242 ; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR
4343
4444 ; REMARK: single-impl: devirtualized a call to _ZN1A1nEi
45
46 ; Next check that we emit an error when trying to LTO link this module
47 ; containing an llvm.type.checked.load (with a split LTO Unit) with one
48 ; that does not have a split LTO Unit.
49 ; RUN: opt -thinlto-bc -o %t2.o %S/Inputs/empty.ll
50 ; RUN: not llvm-lto2 run %t.o %t2.o -save-temps -pass-remarks=. \
51 ; RUN: -verify-machineinstrs=0 \
52 ; RUN: -o %t3 \
53 ; RUN: -r=%t.o,test,px \
54 ; RUN: -r=%t.o,_ZN1A1nEi,p \
55 ; RUN: -r=%t.o,_ZN1B1fEi,p \
56 ; RUN: -r=%t.o,_ZN1C1fEi,p \
57 ; RUN: -r=%t.o,empty,p \
58 ; RUN: -r=%t.o,_ZTV1B, \
59 ; RUN: -r=%t.o,_ZTV1C, \
60 ; RUN: -r=%t.o,_ZN1A1nEi, \
61 ; RUN: -r=%t.o,_ZN1B1fEi, \
62 ; RUN: -r=%t.o,_ZN1C1fEi, \
63 ; RUN: -r=%t.o,_ZTV1B,px \
64 ; RUN: -r=%t.o,_ZTV1C,px 2>&1 | FileCheck %s --check-prefix=ERROR
65 ; ERROR: LLVM ERROR: inconsistent LTO Unit splitting with llvm.type.test or llvm.type.checked.load
4566
4667 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4768 target triple = "x86_64-grtev4-linux-gnu"
22 ; Test to ensure that only referenced type ID records are emitted into
33 ; each distributed index file.
44
5 ; RUN: opt -thinlto-bc -o %t1.o %s
6 ; RUN: opt -thinlto-bc -o %t2.o %p/Inputs/cfi-distributed.ll
5 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t1.o %s
6 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t2.o %p/Inputs/cfi-distributed.ll
77
88 ; RUN: llvm-lto2 run -thinlto-distributed-indexes %t1.o %t2.o \
99 ; RUN: -o %t3 \
None ; RUN: opt -thinlto-bc %s -o %t1.bc
0 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit %s -o %t1.bc
11 ; RUN: llvm-lto2 run -thinlto-distributed-indexes %t1.bc -o %t.out -save-temps \
22 ; RUN: -r %t1.bc,foo,plx \
33 ; RUN: -r %t1.bc,bar,x \
11
22 ; Test CFI through the thin link and backend.
33
4 ; RUN: opt -thinlto-bc -o %t.o %s
4 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t.o %s
55
66 ; Legacy PM
77 ; RUN: llvm-lto2 run -save-temps %t.o \
4141 ; will use the same vtable pointer. Without a dominance check, we could
4242 ; incorrectly devirtualize a->foo() to B::foo();
4343
44 ; RUN: opt -thinlto-bc -o %t.o %s
44 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t.o %s
4545
4646 ; Legacy PM
4747 ; FIXME: Fix machine verifier issues and remove -verify-machineinstrs=0. PR39436.
None ; RUN: opt -thinlto-bc -o %t %s
0 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t %s
11 ; RUN: llvm-modextract -b -n 0 -o - %t | llvm-dis | FileCheck --check-prefix=M0 %s
22 ; RUN: llvm-modextract -b -n 1 -o - %t | llvm-dis | FileCheck --check-prefix=M1 %s
33
None ; RUN: opt -thinlto-bc -o %t %s
0 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t %s
11 ; RUN: llvm-modextract -n 0 -o - %t | llvm-dis | FileCheck --check-prefix=THIN %s
22 ; RUN: llvm-modextract -n 1 -o - %t | llvm-dis | FileCheck --check-prefix=MERGED %s
33
None ; RUN: opt -thinlto-bc -o %t %s
0 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t %s
11 ; RUN: llvm-modextract -n 0 -o - %t | llvm-dis | FileCheck --check-prefix=CHECK0 %s
22 ; RUN: llvm-modextract -n 1 -o - %t | llvm-dis | FileCheck --check-prefix=CHECK1 %s
33 ; CHECK0-NOT: @{{.*}}anon{{.*}}=
None ; RUN: opt -thinlto-bc -o %t %s
0 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t %s
11 ; RUN: llvm-modextract -n 1 -o - %t | llvm-dis | FileCheck --check-prefix=CHECK1 %s
22
33 target triple = "x86_64-unknown-linux-gnu"
0 ; Test for a bug specific to the new pass manager where we may build a domtree
11 ; to make more precise AA queries for functions.
22 ;
3 ; RUN: opt -aa-pipeline=default -passes='no-op-module' -debug-pass-manager -thinlto-bc -o %t %s
3 ; RUN: opt -aa-pipeline=default -passes='no-op-module' -debug-pass-manager -thinlto-bc -thinlto-split-lto-unit -o %t %s
44 ; RUN: llvm-modextract -b -n 0 -o - %t | llvm-dis | FileCheck --check-prefix=M0 %s
55 ; RUN: llvm-modextract -b -n 1 -o - %t | llvm-dis | FileCheck --check-prefix=M1 %s
66
None ; RUN: opt -thinlto-bc -o %t %s
0 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t %s
11 ; RUN: llvm-modextract -b -n 0 -o %t0 %t
22 ; RUN: llvm-modextract -b -n 1 -o %t1 %t
33 ; RUN: not llvm-modextract -b -n 2 -o - %t 2>&1 | FileCheck --check-prefix=ERROR %s
None ; RUN: opt -thinlto-bc -o %t %s
0 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t %s
11 ; RUN: llvm-modextract -b -n 0 -o %t0 %t
22 ; RUN: llvm-modextract -b -n 1 -o %t1 %t
33 ; RUN: not llvm-modextract -b -n 2 -o - %t 2>&1 | FileCheck --check-prefix=ERROR %s
None ; RUN: opt -thinlto-bc -o %t %s
0 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t %s
11 ; RUN: llvm-modextract -b -n 0 -o %t0 %t
22 ; RUN: llvm-modextract -b -n 1 -o %t1 %t
33 ; RUN: not llvm-modextract -b -n 2 -o - %t 2>&1 | FileCheck --check-prefix=ERROR %s
None ; RUN: opt -thinlto-bc -o %t %s
0 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t %s
11 ; RUN: llvm-modextract -b -n 0 -o - %t | llvm-dis | FileCheck --check-prefix=M0 %s
22 ; RUN: llvm-modextract -b -n 1 -o - %t | llvm-dis | FileCheck --check-prefix=M1 %s
33
None ; RUN: opt -thinlto-bc -o %t %s
0 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t %s
11 ; RUN: llvm-modextract -b -n 0 -o - %t | llvm-dis | FileCheck --check-prefix=M0 %s
22 ; RUN: llvm-modextract -b -n 1 -o - %t | llvm-dis | FileCheck --check-prefix=M1 %s
33
0 ; Generate bitcode files with summary, as well as minimized bitcode without
11 ; the debug metadata for the thin link.
2 ; RUN: opt -thinlto-bc -thin-link-bitcode-file=%t2 -o %t %s
2 ; RUN: opt -thinlto-bc -thin-link-bitcode-file=%t2 -thinlto-split-lto-unit -o %t %s
33 ; RUN: llvm-modextract -b -n 0 -o %t0.bc %t
44 ; RUN: llvm-modextract -b -n 1 -o %t1.bc %t
55 ; RUN: llvm-modextract -b -n 0 -o %t0.thinlink.bc %t2
None ; RUN: opt -thinlto-bc -o %t %s
0 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t %s
11 ; RUN: llvm-modextract -n 1 -o - %t | llvm-dis | FileCheck %s
22
33 ; The target assembly parser is required to parse the symver directives
None ; RUN: opt -thinlto-bc -thin-link-bitcode-file=%t2 -o %t %s
0 ; RUN: opt -thinlto-bc -thin-link-bitcode-file=%t2 -thinlto-split-lto-unit -o %t %s
11 ; RUN: llvm-dis -o - %t | FileCheck %s
22 ; RUN: llvm-bcanalyzer -dump %t | FileCheck --check-prefix=BCA %s
33 ; When not splitting the module, the thin link bitcode file should simply be a
2727 ret void
2828 }
2929
30 ; CHECK: !llvm.module.flags = !{![[FLAG:[0-9]+]]}
31 ; CHECK: ![[FLAG]] = !{i32 1, !"ThinLTO", i32 0}
30 ; CHECK: !llvm.module.flags = !{![[FLAG1:[0-9]+]], ![[FLAG2:[0-9]+]]}
31 ; CHECK: ![[FLAG1]] = !{i32 1, !"EnableSplitLTOUnit", i32 1}
32 ; CHECK: ![[FLAG2]] = !{i32 1, !"ThinLTO", i32 0}
3233
3334 !0 = !{i32 0, !"typeid"}
None ; RUN: opt -thinlto-bc -o %t %s
0 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t %s
11 ; RUN: llvm-modextract -b -n 0 -o - %t | llvm-dis | FileCheck --check-prefix=M0 %s
22 ; RUN: llvm-modextract -b -n 1 -o - %t | llvm-dis | FileCheck --check-prefix=M1 %s
33
102102 OutputThinLTOBC("thinlto-bc",
103103 cl::desc("Write output as ThinLTO-ready bitcode"));
104104
105 static cl::opt
106 SplitLTOUnit("thinlto-split-lto-unit",
107 cl::desc("Enable splitting of a ThinLTO LTOUnit"));
108
105109 static cl::opt ThinLinkBitcodeFile(
106110 "thin-link-bitcode-file", cl::value_desc("filename"),
107111 cl::desc(
595599 if (CheckBitcodeOutputToConsole(Out->os(), !Quiet))
596600 NoOutput = true;
597601
602 if (OutputThinLTOBC)
603 M->addModuleFlag(Module::Error, "EnableSplitLTOUnit", SplitLTOUnit);
604
598605 if (PassPipeline.getNumOccurrences() > 0) {
599606 OutputKind OK = OK_NoOutput;
600607 if (!NoOutput)