From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9D1533AA9C5F; Thu, 24 Jun 2021 11:12:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9D1533AA9C5F From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/101163] slow compilation for huge classes (>20k members functions) Date: Thu, 24 Jun 2021 11:12:47 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 6.3.0 X-Bugzilla-Keywords: compile-time-hog X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jun 2021 11:12:47 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101163 --- Comment #6 from Jakub Jelinek --- Yes, the C++ FE has quadratic behavior here: #define A(n) int f##n; #define B(n) A(n##0) A(n##1) A(n##2) A(n##3) A(n##4) A(n##5) A(n##6) A(n##7) A(n##8) A(n##9) #define C(n) B(n##0) B(n##1) B(n##2) B(n##3) B(n##4) B(n##5) B(n##6) B(n##7) B(n##8) B(n##9) #define D(n) C(n##0) C(n##1) C(n##2) C(n##3) C(n##4) C(n##5) C(n##6) C(n##7) C(n##8) C(n##9) #define E(n) D(n##0) D(n##1) D(n##2) D(n##3) D(n##4) D(n##5) D(n##6) D(n##7) D(n##8) D(n##9) #define F(n) E(n##0) E(n##1) E(n##2) E(n##3) E(n##4) E(n##5) E(n##6) E(n##7) E(n##8) E(n##9) #define G(n) F(n##0) F(n##1) F(n##2) F(n##3) F(n##4) F(n##5) F(n##6) F(n##7) F(n##8) F(n##9) struct S { E(0) E(1) E(2) E(3) E(4) E(5) E(6) }; The C FE too, but only in checking builds ( 3358 #ifdef ENABLE_TREE_CHECKING 3359 { 3360 tree t2; 3361 for (t2 =3D op2; t2; t2 =3D TREE_CHAIN (t2)) 3362 gcc_assert (t2 !=3D t1); 3363 } 3364 #endif in chainon). E(0) E(1) E(2) E(3) E(4) E(5)=20 time ~/src/gcc/obj88/gcc/cc1 -quiet pr101164.C real 0m15.515s user 0m15.430s sys 0m0.037s time ~/src/gcc/obj88/gcc/cc1plus -quiet pr101164.C real 0m25.771s user 0m25.654s sys 0m0.036s E(0) E(1) E(2) E(3) E(4) E(5) E(6) time ~/src/gcc/obj88/gcc/cc1 -quiet pr101164.C real 0m20.994s user 0m20.875s sys 0m0.050s time ~/src/gcc/obj88/gcc/cc1plus -quiet pr101164.C real 0m35.292s user 0m35.138s sys 0m0.035s In the C++ case it is #0 fields_linear_search (klass=3D, name=3D, want_type=3Dtrue) at ../../gcc/cp/name-lookup.c:1799 #1 0x0000000000c7b400 in get_class_binding_direct (klass=3D, name=3D, want_type=3Dtrue) at ../../gcc/cp/name-lookup.c:1881 #2 0x0000000000c7b9be in get_class_binding (klass=3D, name=3D, want_type=3Dtrue) at ../../gcc/cp/name-lookup.c:1950 #3 0x0000000000db109c in lookup_field_r (binfo=3D, data=3D0x7fffffffcb20) at ../../gcc/cp/search.c:1023 #4 0x0000000000db2324 in dfs_walk_all (binfo=3D, pre_fn=3D0xdb0f2c , post_fn=3D0x0, data=3D0x7fffffffcb20) at ../../gcc/cp/search.c:1453 #5 0x0000000000db1711 in lookup_member (xbasetype=3D, name=3D, protect=3D2, want_type=3Dtr= ue, complain=3D3, afi=3D0x0) at ../../gcc/cp/search.c:1166 #6 0x0000000000c8a8be in get_class_binding (name=3D, scope=3D0x7fffea04ce10) at ../../gcc/cp/name-lookup.c:5333 #7 0x0000000000c8b158 in push_class_level_binding_1 (name=3D, x=3D) at ../../gcc/cp/name-lookup.c:5439 #8 0x0000000000c8b669 in push_class_level_binding (name=3D, x=3D) at ../../gcc/cp/name-lookup.c:5545 #9 0x0000000000c8a49e in pushdecl_class_level (x=3D) at ../../gcc/cp/name-lookup.c:5280 #10 0x0000000000dc3866 in finish_member_declaration (decl=3D) at ../../gcc/cp/semantics.c:3521 #11 0x0000000000cd2d68 in cp_parser_member_declaration (parser=3D0x7fffea06= e7b8) at ../../gcc/cp/parser.c:26627 #12 0x0000000000cd17dc in cp_parser_member_specification_opt (parser=3D0x7fffea06e7b8) at ../../gcc/cp/parser.c:25990 #13 0x0000000000ccf414 in cp_parser_class_specifier_1 (parser=3D0x7fffea06e= 7b8) at ../../gcc/cp/parser.c:25061 #14 0x0000000000cd057a in cp_parser_class_specifier (parser=3D0x7fffea06e7b= 8) at ../../gcc/cp/parser.c:25377 #15 0x0000000000cc1a1a in cp_parser_type_specifier (parser=3D0x7fffea06e7b8, flags=3D1, decl_specs=3D0x7fffffffd410, is_declaration=3Dtrue, declares_class_or_enum=3D0x7fffffffd37c,=20 is_cv_qualifier=3D0x7fffffffd37b) at ../../gcc/cp/parser.c:18609 #16 0x0000000000cbc00e in cp_parser_decl_specifier_seq (parser=3D0x7fffea06= e7b8, flags=3D1, decl_specs=3D0x7fffffffd410, declares_class_or_enum=3D0x7fffffff= d40c) at ../../gcc/cp/parser.c:15210 #17 0x0000000000cba6ff in cp_parser_simple_declaration (parser=3D0x7fffea06= e7b8, function_definition_allowed_p=3Dtrue, maybe_range_for_decl=3D0x0) at ../../gcc/cp/parser.c:14466 #18 0x0000000000cba687 in cp_parser_block_declaration (parser=3D0x7fffea06e= 7b8, statement_p=3Dfalse) at ../../gcc/cp/parser.c:14413 #19 0x0000000000cba353 in cp_parser_declaration (parser=3D0x7fffea06e7b8, prefix_attrs=3D) at ../../gcc/cp/parser.c:14284 #20 0x0000000000cba448 in cp_parser_toplevel_declaration (parser=3D0x7fffea06e7b8) at ../../gcc/cp/parser.c:14313 #21 0x0000000000ca5568 in cp_parser_translation_unit (parser=3D0x7fffea06e7= b8) at ../../gcc/cp/parser.c:4942=