[lld] 6e513a5 - [ELF] Move a computeIsPreemptible() pass into ICF. NFC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 10 22:22:54 PST 2019


Author: Fangrui Song
Date: 2019-12-10T22:21:05-08:00
New Revision: 6e513a53824ffd92765360023d9ef13bdf4c1c76

URL: https://github.com/llvm/llvm-project/commit/6e513a53824ffd92765360023d9ef13bdf4c1c76
DIFF: https://github.com/llvm/llvm-project/commit/6e513a53824ffd92765360023d9ef13bdf4c1c76.diff

LOG: [ELF] Move a computeIsPreemptible() pass into ICF. NFC

Address post-commit review for D71163.

Reviewed By: ruiu

Differential Revision: https://reviews.llvm.org/D71326

Added: 
    

Modified: 
    lld/ELF/Driver.cpp
    lld/ELF/ICF.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index f83166870a43..a0987259d24b 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -1989,11 +1989,6 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
   // Two input sections with 
diff erent 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 95f26c46b375..5e38066f45ba 100644
--- a/lld/ELF/ICF.cpp
+++ b/lld/ELF/ICF.cpp
@@ -452,6 +452,12 @@ static void print(const Twine &s) {
 
 // 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);


        


More information about the llvm-commits mailing list