[ELF] Check --orphan-handling=place (default value) early
authorFangrui Song <i@maskray.me>
Sun, 29 Nov 2020 20:36:26 +0000 (12:36 -0800)
committerFangrui Song <i@maskray.me>
Sun, 29 Nov 2020 20:36:27 +0000 (12:36 -0800)
The function took 1% (161MiB clang) to 1.7% (an 4.9GiB executable) time.

lld/ELF/LinkerScript.cpp

index a03e21c..5bb977d 100644 (file)
@@ -802,6 +802,8 @@ void LinkerScript::addOrphanSections() {
 
 void LinkerScript::diagnoseOrphanHandling() const {
   llvm::TimeTraceScope timeScope("Diagnose orphan sections");
+  if (config->orphanHandling == OrphanHandlingPolicy::Place)
+    return;
   for (const InputSectionBase *sec : orphanSections) {
     // Input SHT_REL[A] retained by --emit-relocs are ignored by
     // computeInputSections(). Don't warn/error.
@@ -812,7 +814,7 @@ void LinkerScript::diagnoseOrphanHandling() const {
     StringRef name = getOutputSectionName(sec);
     if (config->orphanHandling == OrphanHandlingPolicy::Error)
       error(toString(sec) + " is being placed in '" + name + "'");
-    else if (config->orphanHandling == OrphanHandlingPolicy::Warn)
+    else
       warn(toString(sec) + " is being placed in '" + name + "'");
   }
 }