forked from OSchip/llvm-project
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
This commit is contained in:
parent
bcab6484eb
commit
3e0b7837bf
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue