summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2016-05-05 16:12:25 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2016-05-05 16:12:25 +0000
commit3e0b7837bfcabb877e5f1a6747335409d367be76 (patch)
tree754e1fdd8a1e9b85f863e18cbe562440e79b5fbf
parentbcab6484ebaa974a7b88259c8bf8f3ec268d3f1f (diff)
downloadbcm5719-llvm-3e0b7837bfcabb877e5f1a6747335409d367be76.tar.gz
bcm5719-llvm-3e0b7837bfcabb877e5f1a6747335409d367be76.zip
Cache result when tail merging too.
This speeds up a link of chromium with -O2 (but no icf,gc) from 1.940664632 to 1.925578119. llvm-svn: 268639
-rw-r--r--lld/ELF/InputSection.cpp5
-rw-r--r--lld/ELF/InputSection.h9
2 files changed, 7 insertions, 7 deletions
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 41703fb73b3..e5fa4089cc0 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -479,14 +479,15 @@ typename ELFT::uint MergeInputSection<ELFT>::getOffset(uintX_t Offset) {
// Compute the Addend and if the Base is cached, return.
uintX_t Addend = Offset - Start;
uintX_t &Base = I->second;
- auto *MOS = static_cast<MergeOutputSection<ELFT> *>(this->OutSec);
- if (!MOS->shouldTailMerge())
+ assert(Base != MergeInputSection<ELFT>::PieceDead);
+ if (Base != MergeInputSection<ELFT>::PieceLive)
return Base + Addend;
// Map the base to the offset in the output section and cache it.
ArrayRef<uint8_t> D = this->getSectionData();
StringRef Data((const char *)D.data(), D.size());
StringRef Entry = Data.substr(Start, End - Start);
+ auto *MOS = static_cast<MergeOutputSection<ELFT> *>(this->OutSec);
Base = MOS->getOffset(Entry);
return Base + Addend;
}
diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h
index ea8fd438cdf..17313d204d3 100644
--- a/lld/ELF/InputSection.h
+++ b/lld/ELF/InputSection.h
@@ -152,12 +152,11 @@ public:
enum {
// The piece is dead.
PieceDead = uintX_t(-1),
- // The piece is live, and an offset has not yet been assigned. After offsets
+ // The piece is live, but an offset has not yet been assigned. After offsets
// have been assigned, if the output section uses tail merging, the field
- // will still have this value and the output section offset is available
- // from MergeOutputSection<ELFT>::getOffset(). Otherwise, this value has no
- // special significance, it just means that the offset is 0.
- PieceLive = uintX_t(0),
+ // will still have this value and the output section offset is computed
+ // lazilly.
+ PieceLive = uintX_t(-2),
};
std::pair<std::pair<uintX_t, uintX_t> *, uintX_t>
OpenPOWER on IntegriCloud