public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug preprocessor/59782] New: libcpp does not avoid bug #48326 when compiled by older GCC
@ 2014-01-12 23:33 michael at talosis dot ca
  2014-01-13  9:53 ` [Bug preprocessor/59782] " rguenth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: michael at talosis dot ca @ 2014-01-12 23:33 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59782

            Bug ID: 59782
           Summary: libcpp does not avoid bug #48326 when compiled by
                    older GCC
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: preprocessor
          Assignee: unassigned at gcc dot gnu.org
          Reporter: michael at talosis dot ca

GCC 4.7.0 and other older versions have a bug (#48326) where the target
attribute can leak, causing illegal instructions to be emitted in code intended
to be generic.

GCC 4.6.0 through 4.8.2 also contain code that triggers this bug, in
libcpp/lex.c.  That file uses the target attribute to opportunistically use
MMX/SSE even in a generic binary.

The result is that bootstrap is blocked if starting from 4.7.0 when the actual
CPU does not support the new instructions.

Currently the problem block of code is preprocessed in if GCC 4.5.0 or later is
detected.  It should instead only be used for 4.7.1 or later.

Note that it is somewhat important to also fix this in 4.7.4.  This bug only
bites when upgrading from an old GCC.  If someone has an old GCC with C++ not
installed, then they cannot move directly to 4.8.x, and will have to build
4.7.x as an intermediate.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug preprocessor/59782] libcpp does not avoid bug #48326 when compiled by older GCC
  2014-01-12 23:33 [Bug preprocessor/59782] New: libcpp does not avoid bug #48326 when compiled by older GCC michael at talosis dot ca
@ 2014-01-13  9:53 ` rguenth at gcc dot gnu.org
  2014-01-13 10:09 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-01-13  9:53 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59782

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |build
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-01-13
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug preprocessor/59782] libcpp does not avoid bug #48326 when compiled by older GCC
  2014-01-12 23:33 [Bug preprocessor/59782] New: libcpp does not avoid bug #48326 when compiled by older GCC michael at talosis dot ca
  2014-01-13  9:53 ` [Bug preprocessor/59782] " rguenth at gcc dot gnu.org
@ 2014-01-13 10:09 ` jakub at gcc dot gnu.org
  2014-01-13 10:59 ` ubizjak at gmail dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-01-13 10:09 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59782

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I'd say for GCC 4.8 we should just replace the conditional with GCC_VERSION >=
4008 and for 4.9 with >= 4009, better trust only the latest version for target
attribute.  libcpp is bootstrapped and thus for bootstraps it will DTRT.

Note, rs6000 now supports the target attribute, so I'd say that lex.c should
start to use it on ppc*.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug preprocessor/59782] libcpp does not avoid bug #48326 when compiled by older GCC
  2014-01-12 23:33 [Bug preprocessor/59782] New: libcpp does not avoid bug #48326 when compiled by older GCC michael at talosis dot ca
  2014-01-13  9:53 ` [Bug preprocessor/59782] " rguenth at gcc dot gnu.org
  2014-01-13 10:09 ` jakub at gcc dot gnu.org
@ 2014-01-13 10:59 ` ubizjak at gmail dot com
  2014-01-14  1:21 ` michael at talosis dot ca
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ubizjak at gmail dot com @ 2014-01-13 10:59 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59782

--- Comment #3 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Jakub Jelinek from comment #2)
> I'd say for GCC 4.8 we should just replace the conditional with GCC_VERSION
> >= 4008 and for 4.9 with >= 4009, better trust only the latest version for
> target attribute.  libcpp is bootstrapped and thus for bootstraps it will
> DTRT.

According to [1], 4.7.1 is already OK, so > 4007 should be enough.

[1] http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48326#c3
>From gcc-bugs-return-440198-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Jan 13 11:18:17 2014
Return-Path: <gcc-bugs-return-440198-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 1040 invoked by alias); 13 Jan 2014 11:18:16 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 388 invoked by uid 48); 13 Jan 2014 11:18:09 -0000
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug testsuite/59494] [4.9 Regression] FAIL: gfortran.dg/vect/fast-math-mgrid-resid.f scan-tree-dump-times optimized "vect_[^\\n]*\\+ " 13
Date: Mon, 13 Jan 2014 11:18:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: testsuite
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: rguenth at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 4.9.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-59494-4-OoMhb7IZwr@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-59494-4@http.gcc.gnu.org/bugzilla/>
References: <bug-59494-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-01/txt/msg01340.txt.bz2
Content-length: 1649

http://gcc.gnu.org/bugzilla/show_bug.cgi?idY494

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #5)
> Alternatively we should just remove that scan-tree-dump-times from the test
> altogether, counting additions where either lhs or rhs1 of addition has
> vect_ in name is quite flawed, we have lots of other vector additions that
> just use anonymous SSA_NAMEs without any name (_114 etc.), but still have
> vector types.
>
> Counting addps etc. insns doesn't work though, there are 23 before and after
> the r156043 change.
>
> Richard, what is your preference here?

Well,

! we want to check that predictive commoning did something on the
! vectorized loop, which means we have to have exactly 13 vector
! additions.

which means to look at the pcom dump (and maybe enhance it).  On
x86_64 the interesting line in -details is

"Unrolling 2 times."

dumped from

  /* Execute the predictive commoning transformations, and possibly unroll the
     loop.  */
  if (unroll)
    {
      struct epcc_data dta;

      if (dump_file && (dump_flags & TDF_DETAILS))
        fprintf (dump_file, "Unrolling %u times.\n", unroll_factor);
...
    }
  else
    {
      if (dump_file && (dump_flags & TDF_DETAILS))
        fprintf (dump_file,
                 "Executing predictive commoning without unrolling.\n");
      execute_pred_commoning (loop, chains, tmp_vars);
    }

a common "Executing predictive commoning on loop %d" would be possibly
useful.  Eventually with "on %d chains" as well.  All of this even without
-details and within the opt-dumping framework (MSG_OPTIMIZED_LOCATIONS).


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug preprocessor/59782] libcpp does not avoid bug #48326 when compiled by older GCC
  2014-01-12 23:33 [Bug preprocessor/59782] New: libcpp does not avoid bug #48326 when compiled by older GCC michael at talosis dot ca
                   ` (2 preceding siblings ...)
  2014-01-13 10:59 ` ubizjak at gmail dot com
@ 2014-01-14  1:21 ` michael at talosis dot ca
  2014-01-15  0:53 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: michael at talosis dot ca @ 2014-01-14  1:21 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59782

--- Comment #4 from Michael Deutschmann <michael at talosis dot ca> ---
> According to [1], 4.7.1 is already OK, so > 4007 should be enough.

But 4.7.0 isn't OK, so >= 4007 isn't enough.  (> 4007 is functionally
equivalent to >= 4008.)

Note that this does make fixing 4.7.4 (which I suggest should be done otherwise
a person starting with 4.7.0, no C++, and a cmov-less processor will face a
circuitous route up to the current version.) a little more complicated. 
GCC_VERSION >= 4007 isn't good enough, but GCC_VERSION >= 4008 would mean that
4.7.4 would never include the MMX code when compiled with itself.  Some would
call that a regression.

It's a simple matter of preprocessor programming to check the patchlevel too,
but it will be an ugly #if statement....

If only there was a NOT_STAGE_1 macro... (is there?).


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug preprocessor/59782] libcpp does not avoid bug #48326 when compiled by older GCC
  2014-01-12 23:33 [Bug preprocessor/59782] New: libcpp does not avoid bug #48326 when compiled by older GCC michael at talosis dot ca
                   ` (3 preceding siblings ...)
  2014-01-14  1:21 ` michael at talosis dot ca
@ 2014-01-15  0:53 ` pinskia at gcc dot gnu.org
  2014-01-15  8:31 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-01-15  0:53 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59782

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Isn't it better to disable this code when not optimizing so that stage 1 is
never miscompiled?


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug preprocessor/59782] libcpp does not avoid bug #48326 when compiled by older GCC
  2014-01-12 23:33 [Bug preprocessor/59782] New: libcpp does not avoid bug #48326 when compiled by older GCC michael at talosis dot ca
                   ` (4 preceding siblings ...)
  2014-01-15  0:53 ` pinskia at gcc dot gnu.org
@ 2014-01-15  8:31 ` jakub at gcc dot gnu.org
  2021-09-02  2:12 ` pinskia at gcc dot gnu.org
  2022-04-10  0:29 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-01-15  8:31 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59782

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Perhaps, but that is not sufficient, if you don't bootstrap the compiler, then
it will still be likely optimized build by the (system?) compiler.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug preprocessor/59782] libcpp does not avoid bug #48326 when compiled by older GCC
  2014-01-12 23:33 [Bug preprocessor/59782] New: libcpp does not avoid bug #48326 when compiled by older GCC michael at talosis dot ca
                   ` (5 preceding siblings ...)
  2014-01-15  8:31 ` jakub at gcc dot gnu.org
@ 2021-09-02  2:12 ` pinskia at gcc dot gnu.org
  2022-04-10  0:29 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-02  2:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59782

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
#if (GCC_VERSION >= 4005) && (__GNUC__ >= 5 || !defined(__PIC__)) &&
(defined(__i386__) || defined(__x86_64__)) && !(defined(__sun__) &&
defined(__svr4__))

I don't know if this is not that important with the requirement of C++11
compiler  now.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug preprocessor/59782] libcpp does not avoid bug #48326 when compiled by older GCC
  2014-01-12 23:33 [Bug preprocessor/59782] New: libcpp does not avoid bug #48326 when compiled by older GCC michael at talosis dot ca
                   ` (6 preceding siblings ...)
  2021-09-02  2:12 ` pinskia at gcc dot gnu.org
@ 2022-04-10  0:29 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-04-10  0:29 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59782

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |WONTFIX

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is a won't fix as GCC 12+ requires GCC 4.8.0+ to build which has the fix.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-04-10  0:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-12 23:33 [Bug preprocessor/59782] New: libcpp does not avoid bug #48326 when compiled by older GCC michael at talosis dot ca
2014-01-13  9:53 ` [Bug preprocessor/59782] " rguenth at gcc dot gnu.org
2014-01-13 10:09 ` jakub at gcc dot gnu.org
2014-01-13 10:59 ` ubizjak at gmail dot com
2014-01-14  1:21 ` michael at talosis dot ca
2014-01-15  0:53 ` pinskia at gcc dot gnu.org
2014-01-15  8:31 ` jakub at gcc dot gnu.org
2021-09-02  2:12 ` pinskia at gcc dot gnu.org
2022-04-10  0:29 ` pinskia 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).