mirror of
https://github.com/intel/llvm.git
synced 2026-01-24 17:01:00 +08:00
[ELF] Simplify --print-icf-sections
This commit is contained in:
@@ -459,11 +459,6 @@ static void combineRelocHashes(unsigned cnt, InputSection *isec,
|
||||
isec->eqClass[(cnt + 1) % 2] = hash | (1U << 31);
|
||||
}
|
||||
|
||||
static void print(Ctx &ctx, const Twine &s) {
|
||||
if (ctx.arg.printIcfSections)
|
||||
Msg(ctx) << 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
|
||||
@@ -544,13 +539,16 @@ template <class ELFT> void ICF<ELFT>::run() {
|
||||
|
||||
Log(ctx) << "ICF needed " << cnt << " iterations";
|
||||
|
||||
auto print = [&ctx = ctx]() -> ELFSyncStream {
|
||||
return {ctx, ctx.arg.printIcfSections ? DiagLevel::Msg : DiagLevel::None};
|
||||
};
|
||||
// Merge sections by the equivalence class.
|
||||
forEachClassRange(0, sections.size(), [&](size_t begin, size_t end) {
|
||||
if (end - begin == 1)
|
||||
return;
|
||||
print(ctx, "selected section " + toStr(ctx, sections[begin]));
|
||||
print() << "selected section " << sections[begin];
|
||||
for (size_t i = begin + 1; i < end; ++i) {
|
||||
print(ctx, " removing identical section " + toStr(ctx, sections[i]));
|
||||
print() << " removing identical section " << sections[i];
|
||||
sections[begin]->replace(sections[i]);
|
||||
|
||||
// At this point we know sections merged are fully identical and hence
|
||||
|
||||
Reference in New Issue
Block a user