From fcd0e2cca0ac9ddfba28729381d486cc60170dc6 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sun, 29 Mar 2026 00:38:03 -0700 Subject: [PATCH] [ELF] Remove redundant sec->repl != sec check in BPSectionOrderer. NFC (#189214) ICF's InputSection::replace() calls markDead() on folded sections, so `!sec->isLive()` already filters them. --- lld/ELF/BPSectionOrderer.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lld/ELF/BPSectionOrderer.cpp b/lld/ELF/BPSectionOrderer.cpp index 38f15b93050c..966108ffb0df 100644 --- a/lld/ELF/BPSectionOrderer.cpp +++ b/lld/ELF/BPSectionOrderer.cpp @@ -77,11 +77,10 @@ DenseMap elf::runBalancedPartitioning( return; auto *sec = dyn_cast_or_null(d->section); // Skip section symbols. Skip empty, discarded, ICF folded sections, .bss. - // Skipping ICF folded sections reduces duplicate detection work in - // BPSectionOrderer. + // ICF folded sections are already dead (!isLive()), so no separate check + // is needed. if (sym.isSection() || !sec || sec->size == 0 || !sec->isLive() || - sec->repl != sec || !sec->content().data() || - !orderer.secToSym.try_emplace(sec, d).second) + !sec->content().data() || !orderer.secToSym.try_emplace(sec, d).second) return; rootSymbolToSectionIdxs[CachedHashStringRef( lld::utils::getRootSymbol(sym.getName()))]