[lld] r313731 - Revert rL313697, "Compact EhSectionPiece from 32 bytes to 16 bytes."

NAKAMURA Takumi via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 20 01:03:19 PDT 2017


Author: chapuni
Date: Wed Sep 20 01:03:18 2017
New Revision: 313731

URL: http://llvm.org/viewvc/llvm-project?rev=313731&view=rev
Log:
Revert rL313697, "Compact EhSectionPiece from 32 bytes to 16 bytes."

It broke selfhosting.
http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/4896

Modified:
    lld/trunk/ELF/EhFrame.cpp
    lld/trunk/ELF/EhFrame.h
    lld/trunk/ELF/InputSection.cpp
    lld/trunk/ELF/InputSection.h
    lld/trunk/ELF/MarkLive.cpp
    lld/trunk/ELF/SyntheticSections.cpp
    lld/trunk/ELF/SyntheticSections.h

Modified: lld/trunk/ELF/EhFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/EhFrame.cpp?rev=313731&r1=313730&r2=313731&view=diff
==============================================================================
--- lld/trunk/ELF/EhFrame.cpp (original)
+++ lld/trunk/ELF/EhFrame.cpp Wed Sep 20 01:03:18 2017
@@ -153,9 +153,8 @@ template <class ELFT> void EhReader<ELFT
   D = D.slice(Size);
 }
 
-template <class ELFT>
-uint8_t elf::getFdeEncoding(EhInputSection *Sec, EhSectionPiece *Piece) {
-  return EhReader<ELFT>(Sec, Piece->data(Sec)).getFdeEncoding();
+template <class ELFT> uint8_t elf::getFdeEncoding(EhSectionPiece *P) {
+  return EhReader<ELFT>(P->Sec, P->data()).getFdeEncoding();
 }
 
 template <class ELFT> uint8_t EhReader<ELFT>::getFdeEncoding() {
@@ -206,11 +205,7 @@ template size_t elf::readEhRecordSize<EL
 template size_t elf::readEhRecordSize<ELF64LE>(InputSectionBase *S, size_t Off);
 template size_t elf::readEhRecordSize<ELF64BE>(InputSectionBase *S, size_t Off);
 
-template uint8_t elf::getFdeEncoding<ELF32LE>(EhInputSection *,
-                                              EhSectionPiece *);
-template uint8_t elf::getFdeEncoding<ELF32BE>(EhInputSection *,
-                                              EhSectionPiece *);
-template uint8_t elf::getFdeEncoding<ELF64LE>(EhInputSection *,
-                                              EhSectionPiece *);
-template uint8_t elf::getFdeEncoding<ELF64BE>(EhInputSection *,
-                                              EhSectionPiece *);
+template uint8_t elf::getFdeEncoding<ELF32LE>(EhSectionPiece *P);
+template uint8_t elf::getFdeEncoding<ELF32BE>(EhSectionPiece *P);
+template uint8_t elf::getFdeEncoding<ELF64LE>(EhSectionPiece *P);
+template uint8_t elf::getFdeEncoding<ELF64BE>(EhSectionPiece *P);

Modified: lld/trunk/ELF/EhFrame.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/EhFrame.h?rev=313731&r1=313730&r2=313731&view=diff
==============================================================================
--- lld/trunk/ELF/EhFrame.h (original)
+++ lld/trunk/ELF/EhFrame.h Wed Sep 20 01:03:18 2017
@@ -14,13 +14,11 @@
 
 namespace lld {
 namespace elf {
-class EhInputSection;
 class InputSectionBase;
 struct EhSectionPiece;
 
 template <class ELFT> size_t readEhRecordSize(InputSectionBase *S, size_t Off);
-template <class ELFT>
-uint8_t getFdeEncoding(EhInputSection *, EhSectionPiece *);
+template <class ELFT> uint8_t getFdeEncoding(EhSectionPiece *P);
 } // namespace elf
 } // namespace lld
 

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=313731&r1=313730&r2=313731&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Wed Sep 20 01:03:18 2017
@@ -870,7 +870,7 @@ void EhInputSection::split(ArrayRef<RelT
   unsigned RelI = 0;
   for (size_t Off = 0, End = Data.size(); Off != End;) {
     size_t Size = readEhRecordSize<ELFT>(this, Off);
-    this->Pieces.emplace_back(Off, Size, getReloc(Off, Size, Rels, RelI));
+    this->Pieces.emplace_back(Off, this, Size, getReloc(Off, Size, Rels, RelI));
     // The empty record is the end marker.
     if (Size == 4)
       break;

Modified: lld/trunk/ELF/InputSection.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=313731&r1=313730&r2=313731&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.h (original)
+++ lld/trunk/ELF/InputSection.h Wed Sep 20 01:03:18 2017
@@ -25,7 +25,6 @@ namespace lld {
 namespace elf {
 
 class DefinedCommon;
-class EhInputSection;
 class SymbolBody;
 struct SectionPiece;
 
@@ -263,16 +262,17 @@ private:
 };
 
 struct EhSectionPiece {
-  EhSectionPiece(size_t Off, uint32_t Size, unsigned FirstRelocation)
-      : InputOff(Off), Size(Size), FirstRelocation(FirstRelocation) {
-    assert(Off < UINT32_MAX && Size < UINT32_MAX);
-  }
+  EhSectionPiece(size_t Off, InputSectionBase *Sec, uint32_t Size,
+                 unsigned FirstRelocation)
+      : InputOff(Off), Sec(Sec), Size(Size), FirstRelocation(FirstRelocation) {}
+
+  ArrayRef<uint8_t> data() { return {Sec->Data.data() + this->InputOff, Size}; }
 
-  ArrayRef<uint8_t> data(EhInputSection *Sec);
-  uint32_t InputOff;
-  int32_t OutputOff = -1;
+  size_t InputOff;
+  ssize_t OutputOff = -1;
+  InputSectionBase *Sec;
   uint32_t Size;
-  uint32_t FirstRelocation;
+  unsigned FirstRelocation;
 };
 
 // This corresponds to a .eh_frame section of an input file.
@@ -292,10 +292,6 @@ public:
   SyntheticSection *getParent() const;
 };
 
-inline ArrayRef<uint8_t> EhSectionPiece::data(EhInputSection *Sec) {
-  return {Sec->Data.data() + InputOff, Size};
-}
-
 // This is a section that is added directly to an output section
 // instead of needing special combination via a synthetic section. This
 // includes all input sections with the exceptions of SHF_MERGE and

Modified: lld/trunk/ELF/MarkLive.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/MarkLive.cpp?rev=313731&r1=313730&r2=313731&view=diff
==============================================================================
--- lld/trunk/ELF/MarkLive.cpp (original)
+++ lld/trunk/ELF/MarkLive.cpp Wed Sep 20 01:03:18 2017
@@ -126,7 +126,7 @@ scanEhFrameSection(EhInputSection &EH, A
     unsigned FirstRelI = Piece.FirstRelocation;
     if (FirstRelI == (unsigned)-1)
       continue;
-    if (read32<E>(Piece.data(&EH).data() + 4) == 0) {
+    if (read32<E>(Piece.data().data() + 4) == 0) {
       // This is a CIE, we only need to worry about the first relocation. It is
       // known to point to the personality function.
       resolveReloc<ELFT>(EH, Rels[FirstRelI], Fn);

Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=313731&r1=313730&r2=313731&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Wed Sep 20 01:03:18 2017
@@ -403,11 +403,11 @@ EhFrameSection<ELFT>::EhFrameSection()
 // and where their relocations point to.
 template <class ELFT>
 template <class RelTy>
-CieRecord *EhFrameSection<ELFT>::addCie(EhInputSection *Sec,
-                                        EhSectionPiece &Cie,
+CieRecord *EhFrameSection<ELFT>::addCie(EhSectionPiece &Cie,
                                         ArrayRef<RelTy> Rels) {
+  auto *Sec = cast<EhInputSection>(Cie.Sec);
   const endianness E = ELFT::TargetEndianness;
-  if (read32<E>(Cie.data(Sec).data() + 4) != 0)
+  if (read32<E>(Cie.data().data() + 4) != 0)
     fatal(toString(Sec) + ": CIE expected at beginning of .eh_frame");
 
   SymbolBody *Personality = nullptr;
@@ -417,11 +417,10 @@ CieRecord *EhFrameSection<ELFT>::addCie(
         &Sec->template getFile<ELFT>()->getRelocTargetSym(Rels[FirstRelI]);
 
   // Search for an existing CIE by CIE contents/relocation target pair.
-  CieRecord *Rec = &CieMap[{Cie.data(Sec), Personality}];
+  CieRecord *Rec = &CieMap[{Cie.data(), Personality}];
 
   // If not found, create a new one.
-  if (Rec->Sec == nullptr) {
-    Rec->Sec = Sec;
+  if (Rec->Cie == nullptr) {
     Rec->Cie = &Cie;
     CieRecords.push_back(Rec);
   }
@@ -432,8 +431,9 @@ CieRecord *EhFrameSection<ELFT>::addCie(
 // points to a live function.
 template <class ELFT>
 template <class RelTy>
-bool EhFrameSection<ELFT>::isFdeLive(EhInputSection *Sec, EhSectionPiece &Fde,
+bool EhFrameSection<ELFT>::isFdeLive(EhSectionPiece &Fde,
                                      ArrayRef<RelTy> Rels) {
+  auto *Sec = cast<EhInputSection>(Fde.Sec);
   unsigned FirstRelI = Fde.FirstRelocation;
 
   // An FDE should point to some function because FDEs are to describe
@@ -469,9 +469,9 @@ void EhFrameSection<ELFT>::addSectionAux
       return;
 
     size_t Offset = Piece.InputOff;
-    uint32_t ID = read32<E>(Piece.data(Sec).data() + 4);
+    uint32_t ID = read32<E>(Piece.data().data() + 4);
     if (ID == 0) {
-      OffsetToCie[Offset] = addCie(Sec, Piece, Rels);
+      OffsetToCie[Offset] = addCie(Piece, Rels);
       continue;
     }
 
@@ -480,7 +480,7 @@ void EhFrameSection<ELFT>::addSectionAux
     if (!Rec)
       fatal(toString(Sec) + ": invalid CIE reference");
 
-    if (!isFdeLive(Sec, Piece, Rels))
+    if (!isFdeLive(Piece, Rels))
       continue;
     Rec->Fdes.push_back(&Piece);
     NumFdes++;
@@ -586,11 +586,11 @@ template <class ELFT> void EhFrameSectio
   const endianness E = ELFT::TargetEndianness;
   for (CieRecord *Rec : CieRecords) {
     size_t CieOffset = Rec->Cie->OutputOff;
-    writeCieFde<ELFT>(Buf + CieOffset, Rec->Cie->data(Rec->Sec));
+    writeCieFde<ELFT>(Buf + CieOffset, Rec->Cie->data());
 
     for (EhSectionPiece *Fde : Rec->Fdes) {
       size_t Off = Fde->OutputOff;
-      writeCieFde<ELFT>(Buf + Off, Fde->data(Rec->Sec));
+      writeCieFde<ELFT>(Buf + Off, Fde->data());
 
       // FDE's second word should have the offset to an associated CIE.
       // Write it.
@@ -606,7 +606,7 @@ template <class ELFT> void EhFrameSectio
   // we obtain two addresses and pass them to EhFrameHdr object.
   if (In<ELFT>::EhFrameHdr) {
     for (CieRecord *Rec : CieRecords) {
-      uint8_t Enc = getFdeEncoding<ELFT>(Rec->Sec, Rec->Cie);
+      uint8_t Enc = getFdeEncoding<ELFT>(Rec->Cie);
       for (EhSectionPiece *Fde : Rec->Fdes) {
         uint64_t Pc = getFdePc(Buf, Fde->OutputOff, Enc);
         uint64_t FdeVA = getParent()->Addr + Fde->OutputOff;

Modified: lld/trunk/ELF/SyntheticSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.h?rev=313731&r1=313730&r2=313731&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.h (original)
+++ lld/trunk/ELF/SyntheticSections.h Wed Sep 20 01:03:18 2017
@@ -59,7 +59,6 @@ public:
 };
 
 struct CieRecord {
-  EhInputSection *Sec = nullptr;
   EhSectionPiece *Cie = nullptr;
   std::vector<EhSectionPiece *> Fdes;
 };
@@ -94,12 +93,10 @@ private:
   void addSectionAux(EhInputSection *S, llvm::ArrayRef<RelTy> Rels);
 
   template <class RelTy>
-  CieRecord *addCie(EhInputSection *Sec, EhSectionPiece &Piece,
-                    ArrayRef<RelTy> Rels);
+  CieRecord *addCie(EhSectionPiece &Piece, ArrayRef<RelTy> Rels);
 
   template <class RelTy>
-  bool isFdeLive(EhInputSection *Sec, EhSectionPiece &Piece,
-                 ArrayRef<RelTy> Rels);
+  bool isFdeLive(EhSectionPiece &Piece, ArrayRef<RelTy> Rels);
 
   uint64_t getFdePc(uint8_t *Buf, size_t Off, uint8_t Enc);
 




More information about the llvm-commits mailing list