https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83309
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org, | |nathan at gcc dot gnu.org --- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> --- The time is spent in fields_linear_search before we build the sorted vector for binary search. #0 0x000000000093d57c in fields_linear_search (klass=<record_type 0x7fffefc169d8 Blah>, name=<identifier_node 0x7fffeec1a880 _x0_68297>, want_type=false) at ../../gcc/cp/name-lookup.c:1165 #1 0x000000000093dfd4 in get_class_binding_direct (klass=<record_type 0x7fffefc169d8 Blah>, name=<identifier_node 0x7fffeec1a880 _x0_68297>, type_or_fns=0) at ../../gcc/cp/name-lookup.c:1270 #2 0x000000000093e524 in get_class_binding (klass=<record_type 0x7fffefc169d8 Blah>, name=<identifier_node 0x7fffeec1a880 _x0_68297>, type_or_fns=0) at ../../gcc/cp/name-lookup.c:1324 #3 0x0000000000a497b1 in lookup_field_r (binfo=<tree_binfo 0x7fffefc1e960>, data=0x7fffffffd4a0) at ../../gcc/cp/search.c:977 #4 0x0000000000a4ac12 in dfs_walk_all (binfo=<tree_binfo 0x7fffefc1e960>, pre_fn=0xa49649 <lookup_field_r(tree, void*)>, post_fn=0x0, data=0x7fffffffd4a0) at ../../gcc/cp/search.c:1410 #5 0x0000000000a4a00b in lookup_member (xbasetype=<tree 0x0>, name=<identifier_node 0x7fffeec1a880 _x0_68297>, protect=2, want_type=false, complain=3, afi=0x0) at ../../gcc/cp/search.c:1134 #6 0x000000000094a586 in get_class_binding (name=<identifier_node 0x7fffeec1a880 _x0_68297>, scope=0x7fffefad8210) at ../../gcc/cp/name-lookup.c:4519 #7 0x000000000094acdb in push_class_level_binding_1 (name=<identifier_node 0x7fffeec1a880 _x0_68297>, x=<field_decl 0x7fffed5674c0 _x0_68297>) at ../../gcc/cp/name-lookup.c:4645 #8 0x000000000094b1e8 in push_class_level_binding (name=<identifier_node 0x7fffeec1a880 _x0_68297>, x=<field_decl 0x7fffed5674c0 _x0_68297>) at ../../gcc/cp/name-lookup.c:4751 #9 0x000000000094a2bb in pushdecl_class_level (x=<field_decl 0x7fffed5674c0 _x0_68297>) at ../../gcc/cp/name-lookup.c:4476 #10 0x0000000000a59308 in finish_member_declaration (decl=<field_decl 0x7fffed5674c0 _x0_68297>) at ../../gcc/cp/semantics.c:3044 Perhaps if fields_linear_search notices more fields than some constant/param, we could build a sorted vector from what we have so far and do the linear search only on the remaining fields and use the partial vector for binary search on the rest? If the linear search on the reminder grows again, sort the remainder and merge the two sorted lists.