public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/12329] New: x86: local function declared with attribute((regparm(3))) gets corrupted parent frame pointer
@ 2003-09-18 15:06 jbeulich at novell dot com
  2003-10-07  2:03 ` [Bug c/12329] " pinskia at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: jbeulich at novell dot com @ 2003-09-18 15:06 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: x86: local function declared with
                    attribute((regparm(3))) gets corrupted parent frame
                    pointer
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jbeulich at novell dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu

Since the parent function's frame pointer is passed in ECX, that register should
not be available for argument passing. However, the third parameter is assigned
to ECX, and thus the callee's assumption of (also) finding the frame pointer
there breaks.

int test(int i) {
	static int __attribute__((__regparm__(3))) stest(int j, int k, int l) {
		return i + j + k + l;
	}
	return stest(i, i, i) * i;
}


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

* [Bug c/12329] x86: local function declared with attribute((regparm(3))) gets corrupted parent frame pointer
  2003-09-18 15:06 [Bug c/12329] New: x86: local function declared with attribute((regparm(3))) gets corrupted parent frame pointer jbeulich at novell dot com
@ 2003-10-07  2:03 ` pinskia at gcc dot gnu dot org
  2003-10-13  5:29 ` [Bug target/12329] " pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-10-07  2:03 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code


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

* [Bug target/12329] x86: local function declared with attribute((regparm(3))) gets corrupted parent frame pointer
  2003-09-18 15:06 [Bug c/12329] New: x86: local function declared with attribute((regparm(3))) gets corrupted parent frame pointer jbeulich at novell dot com
  2003-10-07  2:03 ` [Bug c/12329] " pinskia at gcc dot gnu dot org
@ 2003-10-13  5:29 ` pinskia at gcc dot gnu dot org
  2004-04-27 18:21 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-10-13  5:29 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |target


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

* [Bug target/12329] x86: local function declared with attribute((regparm(3))) gets corrupted parent frame pointer
  2003-09-18 15:06 [Bug c/12329] New: x86: local function declared with attribute((regparm(3))) gets corrupted parent frame pointer jbeulich at novell dot com
  2003-10-07  2:03 ` [Bug c/12329] " pinskia at gcc dot gnu dot org
  2003-10-13  5:29 ` [Bug target/12329] " pinskia at gcc dot gnu dot org
@ 2004-04-27 18:21 ` pinskia at gcc dot gnu dot org
  2004-07-27  2:51 ` pinskia at gcc dot gnu dot org
  2005-07-23  6:01 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-27 18:21 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-04-27 18:09 -------
Confirmed.
It is easier to see on the tree-ssa:
(insn 5 4 6 (set (reg/v:SI 61 [ l ])
        (reg:SI 2 cx [ l ])) -1 (nil)
    (nil))

(insn 6 5 7 (set (reg/f:SI 62 [ CHAIN.6 ])
        (reg:SI 2 cx)) -1 (nil)
    (nil))

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
      Known to fail|                            |2.95.3 3.0.4
   Last reconfirmed|0000-00-00 00:00:00         |2004-04-27 18:09:53
               date|                            |


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


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

* [Bug target/12329] x86: local function declared with attribute((regparm(3))) gets corrupted parent frame pointer
  2003-09-18 15:06 [Bug c/12329] New: x86: local function declared with attribute((regparm(3))) gets corrupted parent frame pointer jbeulich at novell dot com
                   ` (2 preceding siblings ...)
  2004-04-27 18:21 ` pinskia at gcc dot gnu dot org
@ 2004-07-27  2:51 ` pinskia at gcc dot gnu dot org
  2005-07-23  6:01 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-27  2:51 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-07-27 02:51 -------
Basically we should reject attribute((regparm(3))) on nested functions.
Note we already do not put attribute((regparm(3))) on nested functions automatically:
      /* Use register calling convention for local functions when possible.  */
      if (!TARGET_64BIT && !user_convention && decl
          && flag_unit_at_a_time && !profile_flag)
        {
          struct cgraph_local_info *i = cgraph_local_info (decl);
          if (i && i->local)
            {
              /* We can't use regparm(3) for nested functions as these use
                 static chain pointer in third argument.  */
              if (DECL_CONTEXT (decl) && !DECL_NO_STATIC_CHAIN (decl))
                regparm = 2;
              else
                regparm = 3;
            }
        }

-- 


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


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

* [Bug target/12329] x86: local function declared with attribute((regparm(3))) gets corrupted parent frame pointer
  2003-09-18 15:06 [Bug c/12329] New: x86: local function declared with attribute((regparm(3))) gets corrupted parent frame pointer jbeulich at novell dot com
                   ` (3 preceding siblings ...)
  2004-07-27  2:51 ` pinskia at gcc dot gnu dot org
@ 2005-07-23  6:01 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-23  6:01 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
   Last reconfirmed|2005-04-27 00:31:11         |2005-07-23 05:53:30
               date|                            |


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


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

* [Bug target/12329] x86: local function declared with attribute((regparm(3))) gets corrupted parent frame pointer
       [not found] <bug-12329-1068@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2008-04-06  6:42 ` uros at gcc dot gnu dot org
@ 2008-04-06  6:44 ` ubizjak at gmail dot com
  3 siblings, 0 replies; 10+ messages in thread
From: ubizjak at gmail dot com @ 2008-04-06  6:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from ubizjak at gmail dot com  2008-04-06 06:43 -------
Fixed for 4.4.0.


-- 

ubizjak at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.4.0


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


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

* [Bug target/12329] x86: local function declared with attribute((regparm(3))) gets corrupted parent frame pointer
       [not found] <bug-12329-1068@http.gcc.gnu.org/bugzilla/>
  2008-03-22 16:05 ` hjl at gcc dot gnu dot org
  2008-03-22 19:52 ` ubizjak at gmail dot com
@ 2008-04-06  6:42 ` uros at gcc dot gnu dot org
  2008-04-06  6:44 ` ubizjak at gmail dot com
  3 siblings, 0 replies; 10+ messages in thread
From: uros at gcc dot gnu dot org @ 2008-04-06  6:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from uros at gcc dot gnu dot org  2008-04-06 06:41 -------
Subject: Bug 12329

Author: uros
Date: Sun Apr  6 06:40:47 2008
New Revision: 133954

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133954
Log:
        PR target/12329
        * config/i386/i386.c (ix86_function_regparm): Error if regparm(3)
        attribute is used for nested functions.

testsuite/ChangeLog:

        PR target/12329
        * gcc.target/i386/pr12329.c: New test.


Added:
    trunk/gcc/testsuite/gcc.target/i386/pr12329.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug target/12329] x86: local function declared with attribute((regparm(3))) gets corrupted parent frame pointer
       [not found] <bug-12329-1068@http.gcc.gnu.org/bugzilla/>
  2008-03-22 16:05 ` hjl at gcc dot gnu dot org
@ 2008-03-22 19:52 ` ubizjak at gmail dot com
  2008-04-06  6:42 ` uros at gcc dot gnu dot org
  2008-04-06  6:44 ` ubizjak at gmail dot com
  3 siblings, 0 replies; 10+ messages in thread
From: ubizjak at gmail dot com @ 2008-03-22 19:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from ubizjak at gmail dot com  2008-03-22 19:51 -------
(In reply to comment #3)
> Subject: Bug 12329
> 
> Author: hjl
> Date: Sat Mar 22 16:03:57 2008
> New Revision: 133448

According to [1], it is not good to silently change number of passing arguments
for a declared regparm(X) function.

[1] http://gcc.gnu.org/ml/gcc-patches/2008-03/msg01310.html


-- 


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


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

* [Bug target/12329] x86: local function declared with attribute((regparm(3))) gets corrupted parent frame pointer
       [not found] <bug-12329-1068@http.gcc.gnu.org/bugzilla/>
@ 2008-03-22 16:05 ` hjl at gcc dot gnu dot org
  2008-03-22 19:52 ` ubizjak at gmail dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: hjl at gcc dot gnu dot org @ 2008-03-22 16:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from hjl at gcc dot gnu dot org  2008-03-22 16:04 -------
Subject: Bug 12329

Author: hjl
Date: Sat Mar 22 16:03:57 2008
New Revision: 133448

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133448
Log:
gcc/

2008-03-22  Uros Bizjak  <ubizjak@gmail.com>
            H.J. Lu  <hongjiu.lu@intel.com>

        PR target/12329
        * config/i386/i386.c (ix86_function_regparm): Limit the number of
        register passing arguments to 2 for nested functions.

gcc/testsuite/

2008-03-22  Uros Bizjak  <ubizjak@gmail.com>

        PR target/12329
        * gcc.target/i386/pr12329.c: New test.

Added:
    branches/stack/gcc/testsuite/gcc.target/i386/pr12329.c
Modified:
    branches/stack/gcc/ChangeLog.stackalign
    branches/stack/gcc/config/i386/i386.c
    branches/stack/gcc/testsuite/ChangeLog.stackalign


-- 


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


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

end of thread, other threads:[~2008-04-06  6:44 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-18 15:06 [Bug c/12329] New: x86: local function declared with attribute((regparm(3))) gets corrupted parent frame pointer jbeulich at novell dot com
2003-10-07  2:03 ` [Bug c/12329] " pinskia at gcc dot gnu dot org
2003-10-13  5:29 ` [Bug target/12329] " pinskia at gcc dot gnu dot org
2004-04-27 18:21 ` pinskia at gcc dot gnu dot org
2004-07-27  2:51 ` pinskia at gcc dot gnu dot org
2005-07-23  6:01 ` pinskia at gcc dot gnu dot org
     [not found] <bug-12329-1068@http.gcc.gnu.org/bugzilla/>
2008-03-22 16:05 ` hjl at gcc dot gnu dot org
2008-03-22 19:52 ` ubizjak at gmail dot com
2008-04-06  6:42 ` uros at gcc dot gnu dot org
2008-04-06  6:44 ` ubizjak at gmail dot com

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).