Summary: | [3.3 regression] forward template declarations in <complex> let inlining fail | ||
---|---|---|---|
Product: | gcc | Reporter: | Debian GCC Maintainers <debian-gcc> |
Component: | c++ | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | gcc-bugs |
Priority: | P2 | Keywords: | missed-optimization |
Version: | 3.3.2 | ||
Target Milestone: | 3.3.3 | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | 2003-12-25 17:24:05 |
Description
Debian GCC Maintainers
2003-11-17 00:06:03 UTC
The problem is somehow related to having this line: template<typename T> T foo(T); Confirmed on the mainline and 3.3.2. Some how the template is being marked as not inlinable (it does not inline even at -O3). Too much changes for 3.3.3 to fix this one. Maybe I was wrong, this might be fixable for 3.3.3. The problem is that the followard template declaration: template<typename T> T foo(T); Causes all template functions not be defined as inline. Subject: Bug 13081 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2003-12-29 02:42:17 Modified files: gcc/cp : ChangeLog decl.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/opt: inline6.C gcc/testsuite/g++.dg/parse: error9.C Log message: PR c++/13081 * decl.c (duplicate_decls): Preserve inline-ness when redeclaring a function template. PR c++/12613 * decl.c (reshape_init): Reject GNU colon-style designated initializers in arrays. PR c++/13081 * g++.dg/opt/inline6.C: New test. PR c++/12613 * g++.dg/parse/error9.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3837&r2=1.3838 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1168&r2=1.1169 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3315&r2=1.3316 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/inline6.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/error9.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 Fixed in GCC 3.4. Subject: Re: [3.3/3.4 regression] forward template declarations in <complex> let inlining fail > Module name: gcc > Changes by: mmitchel@gcc.gnu.org 2003-12-29 02:42:17 > > Modified files: > gcc/cp : ChangeLog decl.c > gcc/testsuite : ChangeLog > Added files: > gcc/testsuite/g++.dg/opt: inline6.C > gcc/testsuite/g++.dg/parse: error9.C > > Log message: > PR c++/13081 > * decl.c (duplicate_decls): Preserve inline-ness when redeclaring > a function template. > > PR c++/13081 > * g++.dg/opt/inline6.C: New test. backported to the gcc-3_3-branch, no regressions on an i486-linux bootstrap. Ok for the branch? 2003-12-28 Mark Mitchell <mark@codesourcery.com> PR c++/13081 * decl.c (duplicate_decls): Preserve inline-ness when redeclaring a function template. PR c++/13081 * g++.dg/opt/inline6.C: New test. --- gcc/testsuite/g++.dg/opt/inline6.C +++ gcc/testsuite/g++.dg/opt/inline6.C 2003-12-29 09:12:36.000000000 +0000 @@ -0,0 +1,14 @@ +// PR c++/13081 +// { dg-options "-O2" } +// { dg-final { scan-assembler-not "foo" } } + +template<typename T> T foo(T); + +template<typename T> inline T foo(T t) +{ + return t; +} + +void bar (long& l) { + l = foo(l); +} --- gcc/cp/decl.c~ 2003-12-29 10:18:13.000000000 +0100 +++ gcc/cp/decl.c 2003-12-29 10:25:57.000000000 +0100 @@ -3737,6 +3737,14 @@ = DECL_SOURCE_LOCATION (newdecl); } + if (DECL_FUNCTION_TEMPLATE_P (newdecl)) + { + DECL_INLINE (DECL_TEMPLATE_RESULT (olddecl)) + |= DECL_INLINE (DECL_TEMPLATE_RESULT (newdecl)); + DECL_DECLARED_INLINE_P (DECL_TEMPLATE_RESULT (olddecl)) + |= DECL_DECLARED_INLINE_P (DECL_TEMPLATE_RESULT (newdecl)); + } + return 1; } Subject: Re: [3.3/3.4 regression] forward template declarations in <complex> let inlining fail Matthias Klose <doko@cs.tu-berlin.de> writes: | > Module name: gcc | > Changes by: mmitchel@gcc.gnu.org 2003-12-29 02:42:17 | > | > Modified files: | > gcc/cp : ChangeLog decl.c | > gcc/testsuite : ChangeLog | > Added files: | > gcc/testsuite/g++.dg/opt: inline6.C | > gcc/testsuite/g++.dg/parse: error9.C | > | > Log message: | > PR c++/13081 | > * decl.c (duplicate_decls): Preserve inline-ness when redeclaring | > a function template. | > | > PR c++/13081 | > * g++.dg/opt/inline6.C: New test. | | backported to the gcc-3_3-branch, no regressions on an i486-linux | bootstrap. Ok for the branch? Yes, thanks. -- Gaby Subject: Bug 13081 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: doko@gcc.gnu.org 2004-01-02 11:15:04 Modified files: gcc/cp : decl.c ChangeLog gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/opt: inline6.C Log message: 2004-01-02 Matthias Klose <doko@debian.org> Backport from mainline: 2003-12-28 Mark Mitchell <mark@codesourcery.com> PR c++/13081 * decl.c (duplicate_decls): Preserve inline-ness when redeclaring a function template. PR c++/13081 * g++.dg/opt/inline6.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/inline6.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.4.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.965.2.69&r2=1.965.2.70 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.234&r2=1.3076.2.235 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.350&r2=1.2261.2.351 Fixed on the 3.3 branch as well. |