From 048b16f7fbb745635b48d31ee957bb8865597606 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sun, 29 Nov 2020 12:36:26 -0800 Subject: [PATCH] [ELF] Check --orphan-handling=place (default value) early The function took 1% (161MiB clang) to 1.7% (an 4.9GiB executable) time. --- lld/ELF/LinkerScript.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index a03e21c..5bb977d 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -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 + "'"); } } -- 2.7.4