llvm.org GIT mirror llvm / d3f03a6
[ThinLTO] Serialize WithGlobalValueDeadStripping index flag for distributed backends Summary: A recent fix to drop dead symbols (r323633) did not work for ThinLTO distributed backends because we lose the WithGlobalValueDeadStripping set on the index during the thin link. This patch adds a new flags record to the bitcode format for the index, and serializes this flag for the combined index (it would always be 0 for the per-module index generated by the compile step, so no need to serialize the new flags record there until/unless we add another flag that applies to the per-module indexes). Generally this flag should always be set for the distributed backends, which are necessarily performed after the thin link. However, if we were to simply set this flag on the index applied to the distributed backends (invoked via clang), we would lose the ability to disable dead stripping via -compute-dead=false for debugging purposes. Reviewers: grimar, pcc Subscribers: mehdi_amini, inglorion, eraman, llvm-commits Differential Revision: https://reviews.llvm.org/D42799 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@324444 91177308-0d34-0410-b5e6-96231b3b80d8 Teresa Johnson 2 years ago
13 changed file(s) with 48 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
260260 // numrefs x valueid,
261261 // n x (valueid, relblockfreq)]
262262 FS_PERMODULE_RELBF = 19,
263 // Index-wide flags
264 FS_FLAGS = 20,
263265 };
264266
265267 enum MetadataCodes {
51325132 switch (BitCode) {
51335133 default: // Default behavior: ignore.
51345134 break;
5135 case bitc::FS_FLAGS: { // [flags]
5136 uint64_t Flags = Record[0];
5137 // Scan flags (set only on the combined index).
5138 assert(Flags <= 1 && "Unexpected bits in flag");
5139
5140 // 1 bit: WithGlobalValueDeadStripping flag.
5141 if (Flags & 0x1)
5142 TheIndex.setWithGlobalValueDeadStripping();
5143 break;
5144 }
51355145 case bitc::FS_VALUE_GUID: { // [valueid, refguid]
51365146 uint64_t ValueID = Record[0];
51375147 GlobalValue::GUID RefGUID = Record[1];
35513551 Stream.EnterSubblock(bitc::GLOBALVAL_SUMMARY_BLOCK_ID, 3);
35523552 Stream.EmitRecord(bitc::FS_VERSION, ArrayRef{INDEX_VERSION});
35533553
3554 // Write the index flags. Currently we only write a single flag, the value of
3555 // withGlobalValueDeadStripping, which only applies to the combined index.
3556 Stream.EmitRecord(bitc::FS_FLAGS,
3557 ArrayRef{Index.withGlobalValueDeadStripping()});
3558
35543559 for (const auto &GVI : valueIds()) {
35553560 Stream.EmitRecord(bitc::FS_VALUE_GUID,
35563561 ArrayRef{GVI.second, GVI.first});
2121
2222 ; COMBINED:
2323 ; COMBINED-NEXT:
24 ; COMBINED-NEXT:
2425 ; See if the call to analias is registered, using the expected value id.
2526 ; COMBINED-NEXT:
2627 ; COMBINED-NEXT:
0 ; REQUIRES: x86-registered-target
1 ; RUN: opt -module-summary %s -o %t.o
2
3 ; Ensure dead stripping performed flag is set on distributed index
4 ; RUN: llvm-lto2 run %t.o -o %t.out -thinlto-distributed-indexes \
5 ; RUN: -r %t.o,glob,plx
6 ; RUN: llvm-bcanalyzer -dump %t.o.thinlto.bc | FileCheck %s --check-prefix=WITHDEAD
7 ; WITHDEAD:
8
9 ; Ensure dead stripping performed flag is not set on distributed index
10 ; when option used to disable dead stripping computation.
11 ; RUN: llvm-lto2 run %t.o -o %t.out -thinlto-distributed-indexes \
12 ; RUN: -r %t.o,glob,plx -compute-dead=false
13 ; RUN: llvm-bcanalyzer -dump %t.o.thinlto.bc | FileCheck %s --check-prefix=NODEAD
14 ; NODEAD:
15
16 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
17 target triple = "x86_64-unknown-linux-gnu"
18
19 @glob = global i32 0
2323
2424 ; COMBINED:
2525 ; COMBINED-NEXT:
26 ; COMBINED-NEXT:
2627 ; COMBINED-NEXT:
2728 ; COMBINED-NEXT:
2829 ; COMBINED-NEXT:
3636
3737 ; COMBINED:
3838 ; COMBINED-NEXT:
39 ; COMBINED-NEXT:
3940 ; COMBINED-NEXT:
4041 ; COMBINED-NEXT:
4142 ; COMBINED-NEXT:
3838
3939 ; COMBINED:
4040 ; COMBINED-NEXT:
41 ; COMBINED-NEXT:
4142 ; COMBINED-NEXT:
4243 ; COMBINED-NEXT:
4344 ; COMBINED-NEXT:
2525
2626 ; COMBINED:
2727 ; COMBINED-NEXT:
28 ; COMBINED-NEXT:
2829 ; Only 2 VALUE_GUID since reference to undefinedglob should not be included in
2930 ; combined index.
3031 ; COMBINED-NEXT:
44
55 ; COMBINED:
66 ; COMBINED-NEXT:
7 ; COMBINED-NEXT:
78 ; COMBINED-NEXT:
89 ; COMBINED-NEXT:
910 ; COMBINED-NEXT:
9494 ; BACKEND1-NEXT:
9595 ; BACKEND1-NEXT:
9696 ; BACKEND1-NEXT:
97 ; BACKEND1-NEXT:
9798 ; BACKEND1-NEXT:
9899 ; BACKEND1-NEXT:
99100 ; BACKEND1-NEXT:
107108 ; BACKEND2-NEXT:
108109 ; BACKEND2-NEXT:
109110 ; BACKEND2-NEXT:
111 ; BACKEND2-NEXT:
110112 ; BACKEND2-NEXT:
111113 ; BACKEND2-NEXT:
112114 ; BACKEND2-NEXT:
117119 ; COMBINED-NEXT:
118120 ; COMBINED-NEXT:
119121 ; COMBINED-NEXT:
122 ; COMBINED-NEXT:
120123 ; COMBINED-NEXT:
121124 ; COMBINED-NEXT:
122125 ; COMBINED-NEXT:
1010 ; COMBINED-NEXT:
1111 ; COMBINED-NEXT:
1212 ; COMBINED-NEXT:
13 ; COMBINED-NEXT:
1314 ; COMBINED-NEXT:
1415 ; COMBINED-NEXT:
1516 ; COMBINED-NEXT:
314314 STRINGIFY_CODE(FS, COMBINED_ALIAS)
315315 STRINGIFY_CODE(FS, COMBINED_ORIGINAL_NAME)
316316 STRINGIFY_CODE(FS, VERSION)
317 STRINGIFY_CODE(FS, FLAGS)
317318 STRINGIFY_CODE(FS, TYPE_TESTS)
318319 STRINGIFY_CODE(FS, TYPE_TEST_ASSUME_VCALLS)
319320 STRINGIFY_CODE(FS, TYPE_CHECKED_LOAD_VCALLS)