[ELF] Move a computeIsPreemptible() pass into ICF. NFC
Address post-commit review for D71163.
Reviewed By: ruiu
Differential Revision: https://reviews.llvm.org/D71326
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index f831668..a098725 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -1989,11 +1989,6 @@
// Two input sections with different output sections should not be folded.
// ICF runs after processSectionCommands() so that we know the output sections.
if (config->icf != ICFLevel::None) {
- // Compute isPreemptible early to be used by ICF. We may add more symbols
- // later, so this loop cannot be merged with the later computeIsPreemptible
- // pass which is used by scanRelocations().
- for (Symbol *sym : symtab->symbols())
- sym->isPreemptible = computeIsPreemptible(*sym);
findKeepUniqueSections<ELFT>(args);
doIcf<ELFT>();
}
diff --git a/lld/ELF/ICF.cpp b/lld/ELF/ICF.cpp
index 95f26c4..5e38066 100644
--- a/lld/ELF/ICF.cpp
+++ b/lld/ELF/ICF.cpp
@@ -452,6 +452,12 @@
// The main function of ICF.
template <class ELFT> void ICF<ELFT>::run() {
+ // Compute isPreemptible early. We may add more symbols later, so this loop
+ // cannot be merged with the later computeIsPreemptible() pass which is used
+ // by scanRelocations().
+ for (Symbol *sym : symtab->symbols())
+ sym->isPreemptible = computeIsPreemptible(*sym);
+
// Collect sections to merge.
for (InputSectionBase *sec : inputSections) {
auto *s = cast<InputSection>(sec);