[lld] r270325 - Split EHOutputSection<ELFT>::addSectionAux. NFC.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue May 24 08:47:39 PDT 2016
Addressed in r270572. But your comment made me wonder if we should do
binary search rather than sequential search at the last position.
On Tue, May 24, 2016 at 6:24 AM, Rafael EspĂndola <
rafael.espindola at gmail.com> wrote:
> With this change we now scan every relocation for each cie. Before we
> use to use the fact that the relocations are sorted and not start from
> scratch. I measured a 2% performance regression when linking chromium
> with this.
>
> Cheers,
> Rafael
>
>
> On 21 May 2016 at 15:06, Rui Ueyama via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
> > Author: ruiu
> > Date: Sat May 21 14:06:33 2016
> > New Revision: 270325
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=270325&view=rev
> > Log:
> > Split EHOutputSection<ELFT>::addSectionAux. NFC.
> >
> > Modified:
> > lld/trunk/ELF/OutputSections.cpp
> >
> > Modified: lld/trunk/ELF/OutputSections.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=270325&r1=270324&r2=270325&view=diff
> >
> ==============================================================================
> > --- lld/trunk/ELF/OutputSections.cpp (original)
> > +++ lld/trunk/ELF/OutputSections.cpp Sat May 21 14:06:33 2016
> > @@ -1114,6 +1114,19 @@ static typename ELFT::uint readEntryLeng
> > return Len;
> > }
> >
> > +// Returns the first relocation that points to a region
> > +// between Begin and Begin+Size.
> > +template <class IntTy, class RelTy>
> > +static const RelTy *getReloc(IntTy Begin, IntTy Size, ArrayRef<RelTy>
> Rels) {
> > + size_t I = 0;
> > + size_t E = Rels.size();
> > + while (I != E && Rels[I].r_offset < Begin)
> > + ++I;
> > + if (I == E || Begin + Size <= Rels[I].r_offset)
> > + return nullptr;
> > + return &Rels[I];
> > +}
> > +
> > template <class ELFT>
> > template <class RelTy>
> > void EHOutputSection<ELFT>::addSectionAux(EHInputSection<ELFT> *S,
> > @@ -1127,8 +1140,6 @@ void EHOutputSection<ELFT>::addSectionAu
> > ArrayRef<uint8_t> SecData = S->getSectionData();
> > ArrayRef<uint8_t> D = SecData;
> > uintX_t Offset = 0;
> > - auto RelI = Rels.begin();
> > - auto RelE = Rels.end();
> >
> > DenseMap<unsigned, unsigned> OffsetToIndex;
> > while (!D.empty()) {
> > @@ -1142,11 +1153,6 @@ void EHOutputSection<ELFT>::addSectionAu
> > break;
> > StringRef Entry((const char *)D.data(), Length);
> >
> > - while (RelI != RelE && RelI->r_offset < Offset)
> > - ++RelI;
> > - uintX_t NextOffset = Offset + Length;
> > - bool HasReloc = RelI != RelE && RelI->r_offset < NextOffset;
> > -
> > uint32_t ID = read32<E>(D.data() + 4);
> > if (ID == 0) {
> > // CIE
> > @@ -1155,8 +1161,8 @@ void EHOutputSection<ELFT>::addSectionAu
> > C.FdeEncoding = getFdeEncoding(D);
> >
> > SymbolBody *Personality = nullptr;
> > - if (HasReloc)
> > - Personality = &S->getFile()->getRelocTargetSym(*RelI);
> > + if (const RelTy *Rel = getReloc(Offset, Length, Rels))
> > + Personality = &S->getFile()->getRelocTargetSym(*Rel);
> >
> > std::pair<StringRef, SymbolBody *> CieInfo(Entry, Personality);
> > auto P = CieMap.insert(std::make_pair(CieInfo, Cies.size()));
> > @@ -1166,9 +1172,11 @@ void EHOutputSection<ELFT>::addSectionAu
> > }
> > OffsetToIndex[Offset] = P.first->second;
> > } else {
> > - if (!HasReloc)
> > + const RelTy *Rel = getReloc(Offset, Length, Rels);
> > + if (!Rel)
> > fatal("FDE doesn't reference another section");
> > - SymbolBody &B = S->getFile()->getRelocTargetSym(*RelI);
> > + SymbolBody &B = S->getFile()->getRelocTargetSym(*Rel);
> > +
> > auto *D = dyn_cast<DefinedRegular<ELFT>>(&B);
> > if (D && D->Section) {
> > InputSectionBase<ELFT> *Target = D->Section->Repl;
> > @@ -1184,7 +1192,7 @@ void EHOutputSection<ELFT>::addSectionAu
> > }
> > }
> >
> > - Offset = NextOffset;
> > + Offset += Length;
> > D = D.slice(Length);
> > }
> > }
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160524/0cf61fd4/attachment.html>
More information about the llvm-commits
mailing list