[lld] r315137 - Return early. NFC.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 6 17:22:59 PDT 2017


Author: ruiu
Date: Fri Oct  6 17:22:59 2017
New Revision: 315137

URL: http://llvm.org/viewvc/llvm-project?rev=315137&view=rev
Log:
Return early. NFC.

Modified:
    lld/trunk/ELF/OutputSections.cpp

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=315137&r1=315136&r2=315137&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Fri Oct  6 17:22:59 2017
@@ -107,7 +107,16 @@ void OutputSection::addSection(InputSect
   }
 }
 
-static SectionKey createKey(InputSectionBase *C, StringRef OutsecName) {
+static SectionKey createKey(InputSectionBase *IS, StringRef OutsecName) {
+  // When control reaches here, mergeable sections have already been
+  // merged except the -r case. If that's the case, we want to combine
+  // mergeable sections by sh_entsize and sh_flags.
+  if (Config->Relocatable && (IS->Flags & SHF_MERGE)) {
+    uint64_t Flags = IS->Flags & (SHF_MERGE | SHF_STRINGS);
+    uint32_t Alignment = std::max<uint32_t>(IS->Alignment, IS->Entsize);
+    return SectionKey{OutsecName, Flags, Alignment};
+  }
+
   //  The ELF spec just says
   // ----------------------------------------------------------------
   // In the first phase, input sections that match in name, type and
@@ -150,15 +159,7 @@ static SectionKey createKey(InputSection
   //
   // Given the above issues, we instead merge sections by name and error on
   // incompatible types and flags.
-
-  uint32_t Alignment = 0;
-  uint64_t Flags = 0;
-  if (Config->Relocatable && (C->Flags & SHF_MERGE)) {
-    Alignment = std::max<uint64_t>(C->Alignment, C->Entsize);
-    Flags = C->Flags & (SHF_MERGE | SHF_STRINGS);
-  }
-
-  return SectionKey{OutsecName, Flags, Alignment};
+  return SectionKey{OutsecName, 0, 0};
 }
 
 OutputSectionFactory::OutputSectionFactory() {}




More information about the llvm-commits mailing list