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

Address post-commit review for D71163.

Reviewed By: ruiu

Differential Revision: https://reviews.llvm.org/D71326
This commit is contained in:
Fangrui Song 2019-12-10 21:37:57 -08:00
parent 3a713ae5fa
commit 6e513a5382
2 changed files with 6 additions and 5 deletions

View File

@ -1989,11 +1989,6 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
// 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>();
}

View File

@ -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);