https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64500
ak at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ak at gcc dot gnu.org --- Comment #4 from ak at gcc dot gnu.org --- I see the same when building things like LLVM with a modern gcc. push_to_top_level consistently uses 5-6% of the CPU time and is by far the most expensive function of the compiler. The hot comparison is the global_scope_p check below. Need a better data structure? /* Have to include the global scope, because class-scope decls aren't listed anywhere useful. */ for (; b; b = b->level_chain) { tree t; /* Template IDs are inserted into the global level. If they were inserted into namespace level, finish_file wouldn't find them when doing pending instantiations. Therefore, don't stop at namespace level, but continue until :: . */ if (global_scope_p (b)) break;