[llvm] r324444 - [ThinLTO] Serialize WithGlobalValueDeadStripping index flag for distributed backends
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 6 20:05:59 PST 2018
Author: tejohnson
Date: Tue Feb 6 20:05:59 2018
New Revision: 324444
URL: http://llvm.org/viewvc/llvm-project?rev=324444&view=rev
Log:
[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
Added:
llvm/trunk/test/Bitcode/thinlto-deadstrip-flag.ll
Modified:
llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h
llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/trunk/test/Bitcode/thinlto-alias.ll
llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-pgo.ll
llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-profile-summary.ll
llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-sample-profile-summary.ll
llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph.ll
llvm/trunk/test/Bitcode/thinlto-function-summary-originalnames.ll
llvm/trunk/test/tools/gold/X86/thinlto.ll
llvm/trunk/test/tools/llvm-lto/thinlto.ll
llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
Modified: llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h?rev=324444&r1=324443&r2=324444&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h (original)
+++ llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h Tue Feb 6 20:05:59 2018
@@ -261,6 +261,8 @@ enum GlobalValueSummarySymtabCodes {
// numrefs x valueid,
// n x (valueid, relblockfreq)]
FS_PERMODULE_RELBF = 19,
+ // Index-wide flags
+ FS_FLAGS = 20,
};
enum MetadataCodes {
Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=324444&r1=324443&r2=324444&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Tue Feb 6 20:05:59 2018
@@ -5133,6 +5133,16 @@ Error ModuleSummaryIndexBitcodeReader::p
switch (BitCode) {
default: // Default behavior: ignore.
break;
+ case bitc::FS_FLAGS: { // [flags]
+ uint64_t Flags = Record[0];
+ // Scan flags (set only on the combined index).
+ assert(Flags <= 1 && "Unexpected bits in flag");
+
+ // 1 bit: WithGlobalValueDeadStripping flag.
+ if (Flags & 0x1)
+ TheIndex.setWithGlobalValueDeadStripping();
+ break;
+ }
case bitc::FS_VALUE_GUID: { // [valueid, refguid]
uint64_t ValueID = Record[0];
GlobalValue::GUID RefGUID = Record[1];
Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=324444&r1=324443&r2=324444&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Tue Feb 6 20:05:59 2018
@@ -3552,6 +3552,11 @@ void IndexBitcodeWriter::writeCombinedGl
Stream.EnterSubblock(bitc::GLOBALVAL_SUMMARY_BLOCK_ID, 3);
Stream.EmitRecord(bitc::FS_VERSION, ArrayRef<uint64_t>{INDEX_VERSION});
+ // Write the index flags. Currently we only write a single flag, the value of
+ // withGlobalValueDeadStripping, which only applies to the combined index.
+ Stream.EmitRecord(bitc::FS_FLAGS,
+ ArrayRef<uint64_t>{Index.withGlobalValueDeadStripping()});
+
for (const auto &GVI : valueIds()) {
Stream.EmitRecord(bitc::FS_VALUE_GUID,
ArrayRef<uint64_t>{GVI.second, GVI.first});
Modified: llvm/trunk/test/Bitcode/thinlto-alias.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/thinlto-alias.ll?rev=324444&r1=324443&r2=324444&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/thinlto-alias.ll (original)
+++ llvm/trunk/test/Bitcode/thinlto-alias.ll Tue Feb 6 20:05:59 2018
@@ -22,6 +22,7 @@
; COMBINED: <GLOBALVAL_SUMMARY_BLOCK
; COMBINED-NEXT: <VERSION
+; COMBINED-NEXT: <FLAGS
; See if the call to analias is registered, using the expected value id.
; COMBINED-NEXT: <VALUE_GUID op0=[[ALIASID:[0-9]+]] op1=-5751648690987223394/>
; COMBINED-NEXT: <VALUE_GUID
Added: llvm/trunk/test/Bitcode/thinlto-deadstrip-flag.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/thinlto-deadstrip-flag.ll?rev=324444&view=auto
==============================================================================
--- llvm/trunk/test/Bitcode/thinlto-deadstrip-flag.ll (added)
+++ llvm/trunk/test/Bitcode/thinlto-deadstrip-flag.ll Tue Feb 6 20:05:59 2018
@@ -0,0 +1,20 @@
+; REQUIRES: x86-registered-target
+; RUN: opt -module-summary %s -o %t.o
+
+; Ensure dead stripping performed flag is set on distributed index
+; RUN: llvm-lto2 run %t.o -o %t.out -thinlto-distributed-indexes \
+; RUN: -r %t.o,glob,plx
+; RUN: llvm-bcanalyzer -dump %t.o.thinlto.bc | FileCheck %s --check-prefix=WITHDEAD
+; WITHDEAD: <FLAGS op0=1/>
+
+; Ensure dead stripping performed flag is not set on distributed index
+; when option used to disable dead stripping computation.
+; RUN: llvm-lto2 run %t.o -o %t.out -thinlto-distributed-indexes \
+; RUN: -r %t.o,glob,plx -compute-dead=false
+; RUN: llvm-bcanalyzer -dump %t.o.thinlto.bc | FileCheck %s --check-prefix=NODEAD
+; NODEAD: <FLAGS op0=0/>
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+ at glob = global i32 0
Modified: llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-pgo.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-pgo.ll?rev=324444&r1=324443&r2=324444&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-pgo.ll (original)
+++ llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-pgo.ll Tue Feb 6 20:05:59 2018
@@ -24,6 +24,7 @@
; COMBINED: <GLOBALVAL_SUMMARY_BLOCK
; COMBINED-NEXT: <VERSION
+; COMBINED-NEXT: <FLAGS
; COMBINED-NEXT: <VALUE_GUID op0=[[FUNCID:[0-9]+]] op1=7289175272376759421/>
; COMBINED-NEXT: <VALUE_GUID
; COMBINED-NEXT: <COMBINED
Modified: llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-profile-summary.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-profile-summary.ll?rev=324444&r1=324443&r2=324444&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-profile-summary.ll (original)
+++ llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-profile-summary.ll Tue Feb 6 20:05:59 2018
@@ -37,6 +37,7 @@
; COMBINED: <GLOBALVAL_SUMMARY_BLOCK
; COMBINED-NEXT: <VERSION
+; COMBINED-NEXT: <FLAGS
; COMBINED-NEXT: <VALUE_GUID
; COMBINED-NEXT: <VALUE_GUID
; COMBINED-NEXT: <VALUE_GUID
Modified: llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-sample-profile-summary.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-sample-profile-summary.ll?rev=324444&r1=324443&r2=324444&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-sample-profile-summary.ll (original)
+++ llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-sample-profile-summary.ll Tue Feb 6 20:05:59 2018
@@ -39,6 +39,7 @@
; COMBINED: <GLOBALVAL_SUMMARY_BLOCK
; COMBINED-NEXT: <VERSION
+; COMBINED-NEXT: <FLAGS
; COMBINED-NEXT: <VALUE_GUID
; COMBINED-NEXT: <VALUE_GUID
; COMBINED-NEXT: <VALUE_GUID
Modified: llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph.ll?rev=324444&r1=324443&r2=324444&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph.ll (original)
+++ llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph.ll Tue Feb 6 20:05:59 2018
@@ -26,6 +26,7 @@
; COMBINED: <GLOBALVAL_SUMMARY_BLOCK
; COMBINED-NEXT: <VERSION
+; COMBINED-NEXT: <FLAGS
; Only 2 VALUE_GUID since reference to undefinedglob should not be included in
; combined index.
; COMBINED-NEXT: <VALUE_GUID op0=[[FUNCID:[0-9]+]] op1=7289175272376759421/>
Modified: llvm/trunk/test/Bitcode/thinlto-function-summary-originalnames.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/thinlto-function-summary-originalnames.ll?rev=324444&r1=324443&r2=324444&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/thinlto-function-summary-originalnames.ll (original)
+++ llvm/trunk/test/Bitcode/thinlto-function-summary-originalnames.ll Tue Feb 6 20:05:59 2018
@@ -5,6 +5,7 @@
; COMBINED: <GLOBALVAL_SUMMARY_BLOCK
; COMBINED-NEXT: <VERSION
+; COMBINED-NEXT: <FLAGS
; COMBINED-NEXT: <VALUE_GUID {{.*}} op1=4947176790635855146/>
; COMBINED-NEXT: <VALUE_GUID {{.*}} op1=-6591587165810580810/>
; COMBINED-NEXT: <VALUE_GUID {{.*}} op1=-4377693495213223786/>
Modified: llvm/trunk/test/tools/gold/X86/thinlto.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/gold/X86/thinlto.ll?rev=324444&r1=324443&r2=324444&view=diff
==============================================================================
--- llvm/trunk/test/tools/gold/X86/thinlto.ll (original)
+++ llvm/trunk/test/tools/gold/X86/thinlto.ll Tue Feb 6 20:05:59 2018
@@ -95,6 +95,7 @@
; BACKEND1-NEXT: </MODULE_STRTAB_BLOCK
; BACKEND1-NEXT: <GLOBALVAL_SUMMARY_BLOCK
; BACKEND1-NEXT: <VERSION
+; BACKEND1-NEXT: <FLAGS
; BACKEND1-NEXT: <VALUE_GUID op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}}
; BACKEND1-NEXT: <VALUE_GUID op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}}
; BACKEND1-NEXT: <COMBINED
@@ -108,6 +109,7 @@
; BACKEND2-NEXT: </MODULE_STRTAB_BLOCK
; BACKEND2-NEXT: <GLOBALVAL_SUMMARY_BLOCK
; BACKEND2-NEXT: <VERSION
+; BACKEND2-NEXT: <FLAGS
; BACKEND2-NEXT: <VALUE_GUID op0=1 op1=-5300342847281564238
; BACKEND2-NEXT: <COMBINED
; BACKEND2-NEXT: </GLOBALVAL_SUMMARY_BLOCK
@@ -118,6 +120,7 @@
; COMBINED-NEXT: </MODULE_STRTAB_BLOCK
; COMBINED-NEXT: <GLOBALVAL_SUMMARY_BLOCK
; COMBINED-NEXT: <VERSION
+; COMBINED-NEXT: <FLAGS
; COMBINED-NEXT: <VALUE_GUID op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}}
; COMBINED-NEXT: <VALUE_GUID op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}}
; COMBINED-NEXT: <COMBINED
Modified: llvm/trunk/test/tools/llvm-lto/thinlto.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-lto/thinlto.ll?rev=324444&r1=324443&r2=324444&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-lto/thinlto.ll (original)
+++ llvm/trunk/test/tools/llvm-lto/thinlto.ll Tue Feb 6 20:05:59 2018
@@ -11,6 +11,7 @@
; COMBINED-NEXT: </MODULE_STRTAB_BLOCK
; COMBINED-NEXT: <GLOBALVAL_SUMMARY_BLOCK
; COMBINED-NEXT: <VERSION
+; COMBINED-NEXT: <FLAGS
; COMBINED-NEXT: <VALUE_GUID op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}}
; COMBINED-NEXT: <VALUE_GUID op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}}
; COMBINED-NEXT: <COMBINED
Modified: llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp?rev=324444&r1=324443&r2=324444&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp (original)
+++ llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp Tue Feb 6 20:05:59 2018
@@ -315,6 +315,7 @@ static const char *GetCodeName(unsigned
STRINGIFY_CODE(FS, COMBINED_ALIAS)
STRINGIFY_CODE(FS, COMBINED_ORIGINAL_NAME)
STRINGIFY_CODE(FS, VERSION)
+ STRINGIFY_CODE(FS, FLAGS)
STRINGIFY_CODE(FS, TYPE_TESTS)
STRINGIFY_CODE(FS, TYPE_TEST_ASSUME_VCALLS)
STRINGIFY_CODE(FS, TYPE_CHECKED_LOAD_VCALLS)
More information about the llvm-commits
mailing list