1
1
mirror of https://github.com/rui314/mold.git synced 2024-12-28 02:44:48 +03:00
This commit is contained in:
Rui Ueyama 2021-03-07 20:41:51 +09:00
parent b1f5b4f9b7
commit 7dbfb01b10
3 changed files with 10 additions and 3 deletions

View File

@ -115,7 +115,7 @@ static void mark(tbb::concurrent_vector<InputSection *> roots) {
// Remove unreachable sections // Remove unreachable sections
static void sweep() { static void sweep() {
Timer t3("sweep"); Timer t("sweep");
static Counter counter("garbage_sections"); static Counter counter("garbage_sections");
tbb::parallel_for_each(out::objs, [&](ObjectFile *file) { tbb::parallel_for_each(out::objs, [&](ObjectFile *file) {

View File

@ -889,6 +889,9 @@ int main(int argc, char **argv) {
on_complete = fork_child(); on_complete = fork_child();
} }
if (config.print_stats)
Counter::enabled = true;
for (std::string_view arg : config.trace_symbol) for (std::string_view arg : config.trace_symbol)
Symbol::intern(arg)->traced = true; Symbol::intern(arg)->traced = true;

8
mold.h
View File

@ -1102,17 +1102,21 @@ public:
} }
Counter &operator++(int) { Counter &operator++(int) {
values.local()++; if (enabled)
values.local()++;
return *this; return *this;
} }
Counter &operator+=(int delta) { Counter &operator+=(int delta) {
values.local() += delta; if (enabled)
values.local() += delta;
return *this; return *this;
} }
static void print(); static void print();
static inline bool enabled = false;
private: private:
i64 get_value(); i64 get_value();