Skip to content

[lld] NFC. Rename function to better reflect its implementation #136625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lld/ELF/ICF.cpp
Original file line number Diff line number Diff line change
@@ -120,7 +120,7 @@ template <class ELFT> class ICF {
void forEachClassRange(size_t begin, size_t end,
llvm::function_ref<void(size_t, size_t)> fn);

void forEachClass(llvm::function_ref<void(size_t, size_t)> fn);
void parallelForEachClass(llvm::function_ref<void(size_t, size_t)> fn);

Ctx &ctx;
SmallVector<InputSection *, 0> sections;
@@ -432,8 +432,10 @@ void ICF<ELFT>::forEachClassRange(size_t begin, size_t end,
}

// Call Fn on each equivalence class.

template <class ELFT>
void ICF<ELFT>::forEachClass(llvm::function_ref<void(size_t, size_t)> fn) {
void ICF<ELFT>::parallelForEachClass(
llvm::function_ref<void(size_t, size_t)> fn) {
// If threading is disabled or the number of sections are
// too small to use threading, call Fn sequentially.
if (parallel::strategy.ThreadsRequested == 1 || sections.size() < 1024) {
@@ -541,14 +543,14 @@ template <class ELFT> void ICF<ELFT>::run() {
// static content. Use a base offset for these IDs to ensure no overlap with
// the unique IDs already assigned.
uint32_t eqClassBase = ++uniqueId;
forEachClass([&](size_t begin, size_t end) {
parallelForEachClass([&](size_t begin, size_t end) {
segregate(begin, end, eqClassBase, true);
});

// Split groups by comparing relocations until convergence is obtained.
do {
repeat = false;
forEachClass([&](size_t begin, size_t end) {
parallelForEachClass([&](size_t begin, size_t end) {
segregate(begin, end, eqClassBase, false);
});
} while (repeat);