[lld] r283173 - Early return. NFC.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 3 17:46:36 PDT 2016


Author: ruiu
Date: Mon Oct  3 19:46:36 2016
New Revision: 283173

URL: http://llvm.org/viewvc/llvm-project?rev=283173&view=rev
Log:
Early return. NFC.

Modified:
    lld/trunk/ELF/MarkLive.cpp

Modified: lld/trunk/ELF/MarkLive.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/MarkLive.cpp?rev=283173&r1=283172&r2=283173&view=diff
==============================================================================
--- lld/trunk/ELF/MarkLive.cpp (original)
+++ lld/trunk/ELF/MarkLive.cpp Mon Oct  3 19:46:36 2016
@@ -160,8 +160,8 @@ scanEhFrameSection(EhInputSection<ELFT>
 }
 
 // We do not garbage-collect two types of sections:
-// 1) Sections used by the loader (.init, .fini, .ctors, .dtors, .jcr)
-// 2) Not allocatable sections which typically contain debugging information
+// 1) Sections used by the loader (.init, .fini, .ctors, .dtors or .jcr)
+// 2) Non-allocatable sections which typically contain debugging information
 template <class ELFT> static bool isReserved(InputSectionBase<ELFT> *Sec) {
   switch (Sec->getSectionHdr()->sh_type) {
   case SHT_FINI_ARRAY:
@@ -170,15 +170,16 @@ template <class ELFT> static bool isRese
   case SHT_PREINIT_ARRAY:
     return true;
   default:
-    StringRef S = Sec->Name;
+    if (!(Sec->getSectionHdr()->sh_flags & SHF_ALLOC))
+      return true;
 
     // We do not want to reclaim sections if they can be referred
     // by __start_* and __stop_* symbols.
+    StringRef S = Sec->Name;
     if (isValidCIdentifier(S))
       return true;
 
-    bool IsAllocSec = Sec->getSectionHdr()->sh_flags & SHF_ALLOC;
-    return !IsAllocSec || S.startswith(".ctors") || S.startswith(".dtors") ||
+    return S.startswith(".ctors") || S.startswith(".dtors") ||
            S.startswith(".init") || S.startswith(".fini") ||
            S.startswith(".jcr");
   }




More information about the llvm-commits mailing list