[lld] r339003 - [ELF] - Remove dead code from LinkerScript::assignOffsets(). NFC-ihope.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 6 03:44:17 PDT 2018


Author: grimar
Date: Mon Aug  6 03:44:17 2018
New Revision: 339003

URL: http://llvm.org/viewvc/llvm-project?rev=339003&view=rev
Log:
[ELF] - Remove dead code from LinkerScript::assignOffsets(). NFC-ihope.

Some parts of the code changed are a bit old. I found traces in 2016.

Initiall commits has test cases and perhaps reasonable comments.
For example, we had segfaults earlier and had the code to fix them.

Now, in 2018, I think it is excessive to have these parts, because
we do not have segfaults and our code was changed a lot (softly saying).

I reviewed the current sources and I think that at this point of the
execution flow, we should never face with
the conditions checked and so I removing them in this patch.

This helps to cleanup the code.

Modified:
    lld/trunk/ELF/LinkerScript.cpp

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=339003&r1=339002&r2=339003&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Mon Aug  6 03:44:17 2018
@@ -701,6 +701,7 @@ uint64_t LinkerScript::advance(uint64_t
 }
 
 void LinkerScript::output(InputSection *S) {
+  assert(Ctx->OutSec == S->getParent());
   uint64_t Before = advance(0, 1);
   uint64_t Pos = advance(S->getSize(), S->Alignment);
   S->OutSecOff = Pos - S->getSize() - Ctx->OutSec->Addr;
@@ -816,21 +817,8 @@ void LinkerScript::assignOffsets(OutputS
     // Handle a single input section description command.
     // It calculates and assigns the offsets for each section and also
     // updates the output section size.
-    auto *Cmd = cast<InputSectionDescription>(Base);
-    for (InputSection *Sec : Cmd->Sections) {
-      // We tentatively added all synthetic sections at the beginning and
-      // removed empty ones afterwards (because there is no way to know
-      // whether they were going be empty or not other than actually running
-      // linker scripts.) We need to ignore remains of empty sections.
-      if (auto *S = dyn_cast<SyntheticSection>(Sec))
-        if (S->empty())
-          continue;
-
-      if (!Sec->Live)
-        continue;
-      assert(Ctx->OutSec == Sec->getParent());
+    for (InputSection *Sec : cast<InputSectionDescription>(Base)->Sections)
       output(Sec);
-    }
   }
 }
 




More information about the llvm-commits mailing list