public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/57837] New: ARM function pointer tailcall miscompilation regression
@ 2013-07-06 16:16 me at williamgrant dot id.au
  2013-07-10 22:34 ` [Bug target/57837] " ramana at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: me at williamgrant dot id.au @ 2013-07-06 16:16 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 57837
           Summary: ARM function pointer tailcall miscompilation
                    regression
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: me at williamgrant dot id.au

Created attachment 30469
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30469&action=edit
arm.md fix

The fix for PR target/19599 in svn trunk r198928 causes predicated function
pointer tailcalls for some ARM targets to lose their predicate and execute
unconditionally, resulting in a crash or other misbehaviour. I was able to
reproduce the miscompilation, manifesting as a segfault, using -march=armv4t
-marm -O3, as below:

gcc -march=armv4t -marm -O3 -o bx-test bx-test.c

----
void baz() {};

void (*bar)() = baz;

void foo(int c) {
    if (c == 1) {
        foo(0);
    }
    bar();
}

int main(int argc, char **argv) {
    foo(1);
}
----

Today's trunk gives the following asm:

----
foo:
        cmp     r0, #1
        stmfd   sp!, {r4, lr}
        ldr     r4, .L8
        ldrne   r3, [r4]
        ldmnefd sp!, {r4, lr}
         bx     r3      @ indirect register sibling call
----

Note the bx to an r3 that is uninitialised when r0 == 1; it should actually be
a bxne. The bug in arm.md is fairly clear: the %? is missing from two bx
instructions, so the predicate is omitted. After identifying the bad code I
discovered that the issue was raised in review, but deemed irrelevant
(http://gcc.gnu.org/ml/gcc-patches/2013-05/msg01022.html).

The attached patch fixes the bug for me.


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

* [Bug target/57837] ARM function pointer tailcall miscompilation regression
  2013-07-06 16:16 [Bug target/57837] New: ARM function pointer tailcall miscompilation regression me at williamgrant dot id.au
@ 2013-07-10 22:34 ` ramana at gcc dot gnu.org
  2013-07-26  7:02 ` bernd.edlinger at hotmail dot de
  2013-07-26  8:16 ` ramana at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: ramana at gcc dot gnu.org @ 2013-07-10 22:34 UTC (permalink / raw)
  To: gcc-bugs

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

Ramana Radhakrishnan <ramana at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-07-10
                 CC|                            |ramana at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |ramana at gcc dot gnu.org
   Target Milestone|---                         |4.9.0
     Ever confirmed|0                           |1

--- Comment #1 from Ramana Radhakrishnan <ramana at gcc dot gnu.org> ---
mine.


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

* [Bug target/57837] ARM function pointer tailcall miscompilation regression
  2013-07-06 16:16 [Bug target/57837] New: ARM function pointer tailcall miscompilation regression me at williamgrant dot id.au
  2013-07-10 22:34 ` [Bug target/57837] " ramana at gcc dot gnu.org
@ 2013-07-26  7:02 ` bernd.edlinger at hotmail dot de
  2013-07-26  8:16 ` ramana at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: bernd.edlinger at hotmail dot de @ 2013-07-26  7:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
(In reply to Ramana Radhakrishnan from comment #1)
> mine.

fixed with revision 201240 ?


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

* [Bug target/57837] ARM function pointer tailcall miscompilation regression
  2013-07-06 16:16 [Bug target/57837] New: ARM function pointer tailcall miscompilation regression me at williamgrant dot id.au
  2013-07-10 22:34 ` [Bug target/57837] " ramana at gcc dot gnu.org
  2013-07-26  7:02 ` bernd.edlinger at hotmail dot de
@ 2013-07-26  8:16 ` ramana at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: ramana at gcc dot gnu.org @ 2013-07-26  8:16 UTC (permalink / raw)
  To: gcc-bugs

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

Ramana Radhakrishnan <ramana at gcc dot gnu.org> changed:

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

--- Comment #3 from Ramana Radhakrishnan <ramana at gcc dot gnu.org> ---
http://gcc.gnu.org/ml/gcc-cvs/2013-07/msg00672.html
http://gcc.gnu.org/ml/gcc-cvs/2013-07/msg00671.html
http://gcc.gnu.org/ml/gcc-cvs/2013-07/msg00670.html


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

end of thread, other threads:[~2013-07-26  8:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-06 16:16 [Bug target/57837] New: ARM function pointer tailcall miscompilation regression me at williamgrant dot id.au
2013-07-10 22:34 ` [Bug target/57837] " ramana at gcc dot gnu.org
2013-07-26  7:02 ` bernd.edlinger at hotmail dot de
2013-07-26  8:16 ` ramana 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).