public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107163] New: Compile time regression when using templated base classes, virtual method, and Wall
@ 2022-10-05 19:35 cfsteefel at arista dot com
2022-10-05 19:49 ` [Bug c++/107163] Compile time regression when using templated base classes, virtual method, and Wall since r10-2823-g6a07489267e55084 marxin at gcc dot gnu.org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: cfsteefel at arista dot com @ 2022-10-05 19:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107163
Bug ID: 107163
Summary: Compile time regression when using templated base
classes, virtual method, and Wall
Product: gcc
Version: 11.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: cfsteefel at arista dot com
Target Milestone: ---
When using templates to create a recursive base class structure, if the base
class uses a virtual method and -Wall is enabled, g++-11 shows much worse
compile time compared to g++-8.
Consider the following code:
# 0 "test.cpp"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 0 "<command-line>" 2
# 1 "test.cpp"
class BaseType {
virtual int doSomething() {
return 1;
}
};
template< int Seq >
class DerivedType : public DerivedType< Seq - 1 > {
};
template<>
class DerivedType< -1 > : public BaseType {
};
int main() {
auto * d = new DerivedType< COUNT >();
delete d;
return 0;
}
Compiled as:
g++-11 test.cpp -Wall -DCOUNT=200
g++-8 test.cpp -Wall -DCOUNT=200
In g++-11, with COUNT=100, the time to compile is around 2 seconds, while with
COUNT=200, the time is around 1 minute, and COUNT=400 took around 28 minutes.
For comparison, compiling the same code with g++-8 took around .3 seconds, 1.6
seconds, and 22 seconds, respectively.
Removing the virtual will lead to the compile time being near instant again, as
will removing the Wall flag (with g++-11).
Other details:
Compiler versions:
g++ (GCC) 11.3.1 20220421 (Red Hat 11.3.1-2)
g++ (GCC) 8.4.0 20200304 (Red Hat 8.4.0-4)
System:
Centos7 based linux
Compiler output:
test.cpp: In function 'int main()':
test.cpp:20:4: warning: deleting object of polymorphic class type
'DerivedType<100>' which has non-virtual destructor might cause undefined
behavior [-Wdelete-non-virtual-dtor]
20 | delete d;
| ^~~~~~~~
(fixing the warning changes nothing, and seemed to double the compile time).
extra g++-11/8 configuration options:
%{O*:%{!fomit-frame-pointer:-fno-omit-frame-pointer}} \
%{O*:%{!fno-wrapv:-fwrapv}} \
%{O*:%{!freorder-blocks-and-partition:-fno-reorder-blocks-and-partition}} \
%{mfpmath=sse:-msse2} \
%{!fsemantic-interposition:-fno-semantic-interposition} \
%{g:%{!g0:-gdwarf-4}} \
Using godbolt, I can see similar timing for g++-10 and g++-8, so this seems to
be a g++-11 specific regression.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/107163] Compile time regression when using templated base classes, virtual method, and Wall since r10-2823-g6a07489267e55084
2022-10-05 19:35 [Bug c++/107163] New: Compile time regression when using templated base classes, virtual method, and Wall cfsteefel at arista dot com
@ 2022-10-05 19:49 ` marxin at gcc dot gnu.org
2022-10-05 19:53 ` [Bug c++/107163] [10/11/12/13 Regression] huge Compile time " pinskia at gcc dot gnu.org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-10-05 19:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107163
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2022-10-05
Summary|Compile time regression |Compile time regression
|when using templated base |when using templated base
|classes, virtual method, |classes, virtual method,
|and Wall |and Wall since
| |r10-2823-g6a07489267e55084
Ever confirmed|0 |1
CC| |jakub at gcc dot gnu.org,
| |marxin at gcc dot gnu.org
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
With -std=c++17 likely started with r10-2823-g6a07489267e55084.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/107163] [10/11/12/13 Regression] huge Compile time when using templated base classes, virtual method, and Wall since r10-2823-g6a07489267e55084
2022-10-05 19:35 [Bug c++/107163] New: Compile time regression when using templated base classes, virtual method, and Wall cfsteefel at arista dot com
2022-10-05 19:49 ` [Bug c++/107163] Compile time regression when using templated base classes, virtual method, and Wall since r10-2823-g6a07489267e55084 marxin at gcc dot gnu.org
@ 2022-10-05 19:53 ` pinskia at gcc dot gnu.org
2022-10-05 20:39 ` [Bug c++/107163] [10/11/12/13 Regression] huge Compile time increase " redi at gcc dot gnu.org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-05 19:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107163
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |10.5
Summary|Compile time regression |[10/11/12/13 Regression]
|when using templated base |huge Compile time when
|classes, virtual method, |using templated base
|and Wall since |classes, virtual method,
|r10-2823-g6a07489267e55084 |and Wall since
| |r10-2823-g6a07489267e55084
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/107163] [10/11/12/13 Regression] huge Compile time increase when using templated base classes, virtual method, and Wall since r10-2823-g6a07489267e55084
2022-10-05 19:35 [Bug c++/107163] New: Compile time regression when using templated base classes, virtual method, and Wall cfsteefel at arista dot com
2022-10-05 19:49 ` [Bug c++/107163] Compile time regression when using templated base classes, virtual method, and Wall since r10-2823-g6a07489267e55084 marxin at gcc dot gnu.org
2022-10-05 19:53 ` [Bug c++/107163] [10/11/12/13 Regression] huge Compile time " pinskia at gcc dot gnu.org
@ 2022-10-05 20:39 ` redi at gcc dot gnu.org
2022-10-18 8:36 ` rguenth at gcc dot gnu.org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2022-10-05 20:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107163
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Yes, using -std=gnu++14 makes GCC 11 as fast as GCC 8.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/107163] [10/11/12/13 Regression] huge Compile time increase when using templated base classes, virtual method, and Wall since r10-2823-g6a07489267e55084
2022-10-05 19:35 [Bug c++/107163] New: Compile time regression when using templated base classes, virtual method, and Wall cfsteefel at arista dot com
` (2 preceding siblings ...)
2022-10-05 20:39 ` [Bug c++/107163] [10/11/12/13 Regression] huge Compile time increase " redi at gcc dot gnu.org
@ 2022-10-18 8:36 ` rguenth at gcc dot gnu.org
2023-03-23 19:59 ` jason at gcc dot gnu.org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-10-18 8:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107163
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/107163] [10/11/12/13 Regression] huge Compile time increase when using templated base classes, virtual method, and Wall since r10-2823-g6a07489267e55084
2022-10-05 19:35 [Bug c++/107163] New: Compile time regression when using templated base classes, virtual method, and Wall cfsteefel at arista dot com
` (3 preceding siblings ...)
2022-10-18 8:36 ` rguenth at gcc dot gnu.org
@ 2023-03-23 19:59 ` jason at gcc dot gnu.org
2023-03-28 15:27 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jason at gcc dot gnu.org @ 2023-03-23 19:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107163
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu.org
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org
--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
This isn't specific to virtual functions; the same slowdown can be seen with
struct BaseType {
int i;
};
template< int Seq >
class DerivedType : public DerivedType< Seq - 1 > { };
template<>
class DerivedType< -1 > : public BaseType { };
int main() {
DerivedType< COUNT > d;
d.i = 42;
}
The reference to the base member is represented with a long sequence of
COMPONENT_REFs, like
d.derived<5>.derived<4>.derived<3>.derived<2>.derived<1>.derived<0>.derived<-1>.base.i
= 42
and with r10-2823 we check sequence points across each of those .s, with high
algorithmic complexity. Checking across COMPONENT_REF seems unnecessary, since
it just selects a subobject of the LHS, there's no additional evaluation.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/107163] [10/11/12/13 Regression] huge Compile time increase when using templated base classes, virtual method, and Wall since r10-2823-g6a07489267e55084
2022-10-05 19:35 [Bug c++/107163] New: Compile time regression when using templated base classes, virtual method, and Wall cfsteefel at arista dot com
` (4 preceding siblings ...)
2023-03-23 19:59 ` jason at gcc dot gnu.org
@ 2023-03-28 15:27 ` cvs-commit at gcc dot gnu.org
2023-04-18 20:46 ` [Bug c++/107163] [10/11/12 " cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-28 15:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107163
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Jason Merrill <jason@gcc.gnu.org>:
https://gcc.gnu.org/g:0e8fc610fb7112deb8c33c673a52983368dde9b7
commit r13-6910-g0e8fc610fb7112deb8c33c673a52983368dde9b7
Author: Jason Merrill <jason@redhat.com>
Date: Thu Mar 23 15:57:39 2023 -0400
c-family: -Wsequence-point and COMPONENT_REF [PR107163]
The patch for PR91415 fixed -Wsequence-point to treat shifts and ARRAY_REF
as sequenced in C++17, and COMPONENT_REF as well. But this is unnecessary
for COMPONENT_REF, since the RHS is just a FIELD_DECL with no actual
evaluation, and in this testcase handling COMPONENT_REF as sequenced blows
up fast in a deep inheritance tree. Instead, look through it.
PR c++/107163
gcc/c-family/ChangeLog:
* c-common.cc (verify_tree): Don't use sequenced handling
for COMPONENT_REF.
gcc/testsuite/ChangeLog:
* g++.dg/warn/Wsequence-point-5.C: New test.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/107163] [10/11/12 Regression] huge Compile time increase when using templated base classes, virtual method, and Wall since r10-2823-g6a07489267e55084
2022-10-05 19:35 [Bug c++/107163] New: Compile time regression when using templated base classes, virtual method, and Wall cfsteefel at arista dot com
` (5 preceding siblings ...)
2023-03-28 15:27 ` cvs-commit at gcc dot gnu.org
@ 2023-04-18 20:46 ` cvs-commit at gcc dot gnu.org
2023-04-21 20:28 ` [Bug c++/107163] [10/11 " cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-18 20:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107163
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:
https://gcc.gnu.org/g:dcfa9615062c46f3c45c70654ea8fa6719a5f40c
commit r12-9444-gdcfa9615062c46f3c45c70654ea8fa6719a5f40c
Author: Jason Merrill <jason@redhat.com>
Date: Thu Mar 23 15:57:39 2023 -0400
c-family: -Wsequence-point and COMPONENT_REF [PR107163]
The patch for PR91415 fixed -Wsequence-point to treat shifts and ARRAY_REF
as sequenced in C++17, and COMPONENT_REF as well. But this is unnecessary
for COMPONENT_REF, since the RHS is just a FIELD_DECL with no actual
evaluation, and in this testcase handling COMPONENT_REF as sequenced blows
up fast in a deep inheritance tree. Instead, look through it.
PR c++/107163
gcc/c-family/ChangeLog:
* c-common.cc (verify_tree): Don't use sequenced handling
for COMPONENT_REF.
gcc/testsuite/ChangeLog:
* g++.dg/warn/Wsequence-point-5.C: New test.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/107163] [10/11 Regression] huge Compile time increase when using templated base classes, virtual method, and Wall since r10-2823-g6a07489267e55084
2022-10-05 19:35 [Bug c++/107163] New: Compile time regression when using templated base classes, virtual method, and Wall cfsteefel at arista dot com
` (6 preceding siblings ...)
2023-04-18 20:46 ` [Bug c++/107163] [10/11/12 " cvs-commit at gcc dot gnu.org
@ 2023-04-21 20:28 ` cvs-commit at gcc dot gnu.org
2023-04-22 0:23 ` cvs-commit at gcc dot gnu.org
2023-07-07 10:44 ` [Bug c++/107163] [11 " rguenth at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-21 20:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107163
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:
https://gcc.gnu.org/g:e81e393cd864abcd2de02602bd51e435dc28f418
commit r10-11307-ge81e393cd864abcd2de02602bd51e435dc28f418
Author: Jason Merrill <jason@redhat.com>
Date: Thu Mar 23 15:57:39 2023 -0400
c-family: -Wsequence-point and COMPONENT_REF [PR107163]
The patch for PR91415 fixed -Wsequence-point to treat shifts and ARRAY_REF
as sequenced in C++17, and COMPONENT_REF as well. But this is unnecessary
for COMPONENT_REF, since the RHS is just a FIELD_DECL with no actual
evaluation, and in this testcase handling COMPONENT_REF as sequenced blows
up fast in a deep inheritance tree. Instead, look through it.
PR c++/107163
gcc/c-family/ChangeLog:
* c-common.c (verify_tree): Don't use sequenced handling
for COMPONENT_REF.
gcc/testsuite/ChangeLog:
* g++.dg/warn/Wsequence-point-5.C: New test.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/107163] [10/11 Regression] huge Compile time increase when using templated base classes, virtual method, and Wall since r10-2823-g6a07489267e55084
2022-10-05 19:35 [Bug c++/107163] New: Compile time regression when using templated base classes, virtual method, and Wall cfsteefel at arista dot com
` (7 preceding siblings ...)
2023-04-21 20:28 ` [Bug c++/107163] [10/11 " cvs-commit at gcc dot gnu.org
@ 2023-04-22 0:23 ` cvs-commit at gcc dot gnu.org
2023-07-07 10:44 ` [Bug c++/107163] [11 " rguenth at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-22 0:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107163
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:
https://gcc.gnu.org/g:9ab083eb8a96b7f8baf6fe632d03aa496017e456
commit r11-10647-g9ab083eb8a96b7f8baf6fe632d03aa496017e456
Author: Jason Merrill <jason@redhat.com>
Date: Thu Mar 23 15:57:39 2023 -0400
c-family: -Wsequence-point and COMPONENT_REF [PR107163]
The patch for PR91415 fixed -Wsequence-point to treat shifts and ARRAY_REF
as sequenced in C++17, and COMPONENT_REF as well. But this is unnecessary
for COMPONENT_REF, since the RHS is just a FIELD_DECL with no actual
evaluation, and in this testcase handling COMPONENT_REF as sequenced blows
up fast in a deep inheritance tree. Instead, look through it.
PR c++/107163
gcc/c-family/ChangeLog:
* c-common.c (verify_tree): Don't use sequenced handling
for COMPONENT_REF.
gcc/testsuite/ChangeLog:
* g++.dg/warn/Wsequence-point-5.C: New test.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/107163] [11 Regression] huge Compile time increase when using templated base classes, virtual method, and Wall since r10-2823-g6a07489267e55084
2022-10-05 19:35 [Bug c++/107163] New: Compile time regression when using templated base classes, virtual method, and Wall cfsteefel at arista dot com
` (8 preceding siblings ...)
2023-04-22 0:23 ` cvs-commit at gcc dot gnu.org
@ 2023-07-07 10:44 ` rguenth at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07 10:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107163
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|10.5 |11.5
--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 10 branch is being closed.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2023-07-07 10:44 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-05 19:35 [Bug c++/107163] New: Compile time regression when using templated base classes, virtual method, and Wall cfsteefel at arista dot com
2022-10-05 19:49 ` [Bug c++/107163] Compile time regression when using templated base classes, virtual method, and Wall since r10-2823-g6a07489267e55084 marxin at gcc dot gnu.org
2022-10-05 19:53 ` [Bug c++/107163] [10/11/12/13 Regression] huge Compile time " pinskia at gcc dot gnu.org
2022-10-05 20:39 ` [Bug c++/107163] [10/11/12/13 Regression] huge Compile time increase " redi at gcc dot gnu.org
2022-10-18 8:36 ` rguenth at gcc dot gnu.org
2023-03-23 19:59 ` jason at gcc dot gnu.org
2023-03-28 15:27 ` cvs-commit at gcc dot gnu.org
2023-04-18 20:46 ` [Bug c++/107163] [10/11/12 " cvs-commit at gcc dot gnu.org
2023-04-21 20:28 ` [Bug c++/107163] [10/11 " cvs-commit at gcc dot gnu.org
2023-04-22 0:23 ` cvs-commit at gcc dot gnu.org
2023-07-07 10:44 ` [Bug c++/107163] [11 " rguenth at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).