[lld] r330346 - Simplify Repl handling.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 19 10:26:50 PDT 2018


Author: rafael
Date: Thu Apr 19 10:26:50 2018
New Revision: 330346

URL: http://llvm.org/viewvc/llvm-project?rev=330346&view=rev
Log:
Simplify Repl handling.

Now that we don't ICF synthetic sections, we can go back to the old
logic on whose responsibility it is to check Repl.

The idea is that Sec->something() will not check Repl. It is the
responsibility of the caller to find the correct Sec.

Modified:
    lld/trunk/ELF/InputSection.cpp
    lld/trunk/ELF/Symbols.cpp

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=330346&r1=330345&r2=330346&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Thu Apr 19 10:26:50 2018
@@ -143,7 +143,7 @@ uint64_t SectionBase::getOffset(uint64_t
   }
   case Regular:
   case Synthetic:
-    return cast<InputSection>(this->Repl)->OutSecOff + Offset;
+    return cast<InputSection>(this)->OutSecOff + Offset;
   case EHFrame:
     // The file crtbeginT.o has relocations pointing to the start of an empty
     // .eh_frame that is known to be the first in the link. It does that to
@@ -152,8 +152,7 @@ uint64_t SectionBase::getOffset(uint64_t
   case Merge:
     const MergeInputSection *MS = cast<MergeInputSection>(this);
     if (InputSection *IS = MS->getParent())
-      return cast<InputSection>(IS->Repl)->OutSecOff +
-             MS->getParentOffset(Offset);
+      return IS->OutSecOff + MS->getParentOffset(Offset);
     return MS->getParentOffset(Offset);
   }
   llvm_unreachable("invalid section kind");
@@ -174,7 +173,7 @@ OutputSection *SectionBase::getOutputSec
     Sec = EH->getParent();
   else
     return cast<OutputSection>(this);
-  return Sec ? cast<InputSection>(Sec->Repl)->getParent() : nullptr;
+  return Sec ? Sec->getParent() : nullptr;
 }
 
 // Decompress section contents if required. Note that this function

Modified: lld/trunk/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=330346&r1=330345&r2=330346&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.cpp (original)
+++ lld/trunk/ELF/Symbols.cpp Thu Apr 19 10:26:50 2018
@@ -57,6 +57,8 @@ static uint64_t getSymVA(const Symbol &S
     if (!IS)
       return D.Value;
 
+    IS = IS->Repl;
+
     uint64_t Offset = D.Value;
 
     // An object in an SHF_MERGE section might be referenced via a
@@ -151,7 +153,7 @@ uint64_t Symbol::getSize() const {
 OutputSection *Symbol::getOutputSection() const {
   if (auto *S = dyn_cast<Defined>(this)) {
     if (auto *Sec = S->Section)
-      return Sec->getOutputSection();
+      return Sec->Repl->getOutputSection();
     return nullptr;
   }
 




More information about the llvm-commits mailing list