summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2017-01-05 21:34:18 +0000
committerTeresa Johnson <tejohnson@google.com>2017-01-05 21:34:18 +0000
commit6c475a75953811bd14b115f5ab88d61ec996a799 (patch)
tree33245462e72aa549f6fd059ad6dd5f4ba0de6b5f /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parent8f05c786c9996b82055358289c7d2f4c748a21c6 (diff)
downloadbcm5719-llvm-6c475a75953811bd14b115f5ab88d61ec996a799.tar.gz
bcm5719-llvm-6c475a75953811bd14b115f5ab88d61ec996a799.zip
ThinLTO: add early "dead-stripping" on the Index
Summary: Using the linker-supplied list of "preserved" symbols, we can compute the list of "dead" symbols, i.e. the one that are not reachable from a "preserved" symbol transitively on the reference graph. Right now we are using this information to mark these functions as non-eligible for import. The impact is two folds: - Reduction of compile time: we don't import these functions anywhere or import the function these symbols are calling. - The limited number of import/export leads to better internalization. Patch originally by Mehdi Amini. Reviewers: mehdi_amini, pcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D23488 llvm-svn: 291177
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 1a2b72e520c..d9e249aad21 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -802,7 +802,11 @@ static GlobalValueSummary::GVFlags getDecodedGVSummaryFlags(uint64_t RawFlags,
auto Linkage = GlobalValue::LinkageTypes(RawFlags & 0xF); // 4 bits
RawFlags = RawFlags >> 4;
bool NotEligibleToImport = (RawFlags & 0x1) || Version < 3;
- return GlobalValueSummary::GVFlags(Linkage, NotEligibleToImport);
+ // The LiveRoot flag wasn't introduced until version 3. For dead stripping
+ // to work correctly on earlier versions, we must conservatively treat all
+ // values as live.
+ bool LiveRoot = (RawFlags & 0x2) || Version < 3;
+ return GlobalValueSummary::GVFlags(Linkage, NotEligibleToImport, LiveRoot);
}
static GlobalValue::VisibilityTypes getDecodedVisibility(unsigned Val) {
OpenPOWER on IntegriCloud