public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/65402] New: global register variables miscompiled when unit contains sse4.2 functions
@ 2015-03-12 13:32 mattiase at acm dot org
  2021-12-14 18:06 ` [Bug target/65402] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: mattiase at acm dot org @ 2015-03-12 13:32 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 65402
           Summary: global register variables miscompiled when unit
                    contains sse4.2 functions
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mattiase at acm dot org

The mere presence of a function with the attribute target("sse4.2") is enough
for gcc to miscompile other functions with respect to global register
variables:

---------------- code below! -----------------
__attribute__((target("sse4.2"))) void F(void) {}

register long gr1 asm("r12");
register long gr2 asm("r13");

long G(void);

int H(void) {
  gr1 = G();   /* Any code at all, really. */
  return 1;
}
----------------- code above! ----------------

The existence of F causes H to save/restore all global register variables in
its prologue/epilogue, which of course makes these variables impossible to use
inside H. Comment out the definition of F, and the problem disappears.

This occurs in GCC 4.9.2 on x86-64 (Linux), with -O0 or -O2.

Possible workaround: move the register declarations to above F. This is not
always easy (in our case, F is really the stuff in ia32intrin.h that happened
to be included from header files that we need for the types in the register
variable declarations).

Although it's good practice to put the global register declarations at the top
of the unit, not doing so shouldn't cause functions below to be miscompiled.

This appears to be a regression; the bug is not present in GCC 4.8.1.


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

* [Bug target/65402] global register variables miscompiled when unit contains sse4.2 functions
  2015-03-12 13:32 [Bug c/65402] New: global register variables miscompiled when unit contains sse4.2 functions mattiase at acm dot org
@ 2021-12-14 18:06 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-14 18:06 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
   Target Milestone|---                         |5.0
         Resolution|---                         |FIXED
      Known to fail|                            |4.9.0, 4.9.4
      Known to work|                            |4.8.5, 5.1.0

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed in GCC 5.  There has been many fixes to target attribute in the GCC 5
timeframe too.

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

end of thread, other threads:[~2021-12-14 18:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-12 13:32 [Bug c/65402] New: global register variables miscompiled when unit contains sse4.2 functions mattiase at acm dot org
2021-12-14 18:06 ` [Bug target/65402] " 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).