mirror of
https://github.com/rui314/mold.git
synced 2024-09-22 02:20:51 +03:00
wip
This commit is contained in:
parent
8ac3704bd3
commit
c4632f8dae
@ -120,7 +120,7 @@ void gc_sections() {
|
||||
if (config.print_gc_sections)
|
||||
SyncOut() << "removing unused section " << *isec;
|
||||
isec->kill();
|
||||
counter.inc();
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
8
icf.cc
8
icf.cc
@ -98,18 +98,18 @@ static void merge_leaf_nodes() {
|
||||
continue;
|
||||
|
||||
if (!is_eligible(*isec)) {
|
||||
non_eligible.inc();
|
||||
non_eligible++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_leaf(*isec)) {
|
||||
leaf.inc();
|
||||
leaf++;
|
||||
isec->icf_leaf = true;
|
||||
auto [it, inserted] = map.insert({isec, isec});
|
||||
if (!inserted && isec->get_priority() < it->second->get_priority())
|
||||
it->second = isec;
|
||||
} else {
|
||||
eligible.inc();
|
||||
eligible++;
|
||||
isec->icf_eligible = true;
|
||||
}
|
||||
}
|
||||
@ -383,7 +383,7 @@ void icf_sections() {
|
||||
for (i64 j = 0; j < 10; j++) {
|
||||
propagate(digests, edges, edge_indices, slot, ap);
|
||||
slot ^= 1;
|
||||
round.inc();
|
||||
round++;
|
||||
}
|
||||
|
||||
i64 n = count_num_classes(digests[slot]);
|
||||
|
@ -273,7 +273,7 @@ void InputSection::apply_reloc_alloc(u8 *base) {
|
||||
// scan_relocations.
|
||||
void InputSection::apply_reloc_nonalloc(u8 *base) {
|
||||
static Counter counter("reloc_nonalloc");
|
||||
counter.inc(rels.size());
|
||||
counter += rels.size();
|
||||
|
||||
i64 ref_idx = 0;
|
||||
|
||||
@ -343,7 +343,7 @@ void InputSection::scan_relocations() {
|
||||
return;
|
||||
|
||||
static Counter counter("reloc_alloc");
|
||||
counter.inc(rels.size());
|
||||
counter += rels.size();
|
||||
|
||||
this->reldyn_offset = file->num_dynrel * sizeof(ElfRela);
|
||||
this->rel_types.resize(rels.size());
|
||||
@ -552,5 +552,5 @@ MergeableSection::MergeableSection(InputSection *isec)
|
||||
}
|
||||
|
||||
static Counter counter("string_fragments");
|
||||
counter.inc(fragments.size());
|
||||
counter += fragments.size();
|
||||
}
|
||||
|
10
main.cc
10
main.cc
@ -1032,15 +1032,15 @@ static void read_input_files(std::span<std::string_view> args) {
|
||||
static void show_stats() {
|
||||
for (ObjectFile *obj : out::objs) {
|
||||
static Counter defined("defined_syms");
|
||||
defined.inc(obj->first_global - 1);
|
||||
defined += obj->first_global - 1;
|
||||
|
||||
static Counter undefined("undefined_syms");
|
||||
undefined.inc(obj->symbols.size() - obj->first_global);
|
||||
undefined += obj->symbols.size() - obj->first_global;
|
||||
}
|
||||
|
||||
Counter num_input_sections("input_sections");
|
||||
for (ObjectFile *file : out::objs)
|
||||
num_input_sections.inc(file->sections.size());
|
||||
num_input_sections += file->sections.size();
|
||||
|
||||
Counter num_output_chunks("output_out::chunks", out::chunks.size());
|
||||
Counter num_objs("num_objs", out::objs.size());
|
||||
@ -1083,8 +1083,6 @@ int main(int argc, char **argv) {
|
||||
on_complete = fork_child();
|
||||
}
|
||||
|
||||
if (config.stat)
|
||||
Counter::enabled = true;
|
||||
if (config.pie)
|
||||
config.image_base = 0;
|
||||
|
||||
@ -1385,7 +1383,7 @@ int main(int argc, char **argv) {
|
||||
print_map();
|
||||
|
||||
// Show stats numbers
|
||||
if (Counter::enabled)
|
||||
if (config.stat)
|
||||
show_stats();
|
||||
|
||||
if (config.perf)
|
||||
|
12
mold.h
12
mold.h
@ -1036,13 +1036,17 @@ public:
|
||||
instances.push_back(this);
|
||||
}
|
||||
|
||||
void inc(i64 delta = 1) {
|
||||
if (enabled)
|
||||
values.local() += delta;
|
||||
Counter &operator++(int) {
|
||||
values.local()++;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Counter &operator+=(int delta) {
|
||||
values.local() += delta;
|
||||
return *this;
|
||||
}
|
||||
|
||||
static void print();
|
||||
static inline bool enabled = false;
|
||||
|
||||
private:
|
||||
i64 get_value();
|
||||
|
@ -138,7 +138,7 @@ void ObjectFile::initialize_sections() {
|
||||
comdat_groups.push_back({group, entries});
|
||||
|
||||
static Counter counter("comdats");
|
||||
counter.inc();
|
||||
counter++;
|
||||
break;
|
||||
}
|
||||
case SHT_SYMTAB_SHNDX:
|
||||
@ -152,7 +152,7 @@ void ObjectFile::initialize_sections() {
|
||||
break;
|
||||
default: {
|
||||
static Counter counter("regular_sections");
|
||||
counter.inc();
|
||||
counter++;
|
||||
|
||||
std::string_view name = shstrtab.data() + shdr.sh_name;
|
||||
this->sections[i] = new InputSection(this, shdr, name, i);
|
||||
@ -342,7 +342,7 @@ void ObjectFile::initialize_symbols() {
|
||||
return;
|
||||
|
||||
static Counter counter("all_syms");
|
||||
counter.inc(elf_syms.size());
|
||||
counter += elf_syms.size();
|
||||
|
||||
// Initialize local symbols
|
||||
Symbol *locals = new Symbol[first_global];
|
||||
@ -657,7 +657,7 @@ void ObjectFile::eliminate_duplicate_comdat_groups() {
|
||||
sections[i]->kill();
|
||||
|
||||
static Counter counter("removed_comdat_mem");
|
||||
counter.inc(entries.size());
|
||||
counter += entries.size();
|
||||
}
|
||||
}
|
||||
|
||||
@ -913,7 +913,7 @@ void SharedFile::parse() {
|
||||
}
|
||||
|
||||
static Counter counter("dso_syms");
|
||||
counter.inc(elf_syms.size());
|
||||
counter += elf_syms.size();
|
||||
}
|
||||
|
||||
std::vector<std::string_view> SharedFile::read_verdef() {
|
||||
|
@ -288,7 +288,7 @@ void SymtabSection::update_shdr() {
|
||||
shdr.sh_link = out::strtab->shndx;
|
||||
|
||||
static Counter counter("symtab");
|
||||
counter.inc(shdr.sh_size / sizeof(ElfSym));
|
||||
counter += shdr.sh_size / sizeof(ElfSym);
|
||||
}
|
||||
|
||||
void SymtabSection::copy_buf() {
|
||||
@ -808,7 +808,7 @@ void MergedSection::copy_buf() {
|
||||
});
|
||||
|
||||
static Counter merged_strings("merged_strings");
|
||||
merged_strings.inc(map.size());
|
||||
merged_strings += map.size();
|
||||
}
|
||||
|
||||
void EhFrameSection::construct() {
|
||||
|
Loading…
Reference in New Issue
Block a user