[lld] r335973 - [ELF] - Eliminate dead code from shouldKeepInSymtab. NFC.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 29 06:34:05 PDT 2018


Author: grimar
Date: Fri Jun 29 06:34:05 2018
New Revision: 335973

URL: http://llvm.org/viewvc/llvm-project?rev=335973&view=rev
Log:
[ELF] - Eliminate dead code from shouldKeepInSymtab. NFC.

shouldKeepInSymtab is called from copyLocalSymbols:
https://github.com/llvm-mirror/lld/blob/master/ELF/Writer.cpp#L574

The pre-condition is that symbol should be Defined:
https://github.com/llvm-mirror/lld/blob/master/ELF/Writer.cpp#L572

And its section is Live:
https://github.com/llvm-mirror/lld/blob/master/ELF/Writer.cpp#L548

InputSection::Discarded section can never be Live. And hence I believe
check I removed in this patch is excessive.

Modified:
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=335973&r1=335972&r2=335973&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Fri Jun 29 06:34:05 2018
@@ -513,9 +513,6 @@ static bool shouldKeepInSymtab(SectionBa
   if (B.isSection())
     return false;
 
-  // If sym references a section in a discarded group, don't keep it.
-  if (Sec == &InputSection::Discarded)
-    return false;
 
   if (Config->Discard == DiscardPolicy::None)
     return true;




More information about the llvm-commits mailing list