public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/16559] New: Incorrect code generated for function pointer
@ 2004-07-15  7:04 hjl at lucon dot org
  2004-07-15  7:07 ` [Bug target/16559] " hjl at lucon dot org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: hjl at lucon dot org @ 2004-07-15  7:04 UTC (permalink / raw)
  To: gcc-bugs

Under certain conditions, gcc 3.3 generates

        addl r14 = @ltoffx(os_boot_rendez#), r1
        ...
        ld8.mov r14 = [r14], os_boot_rendez#

to access the function, os_boot_rendez, which is incorrect.

-- 
           Summary: Incorrect code generated for function pointer
           Product: gcc
           Version: 3.3.5
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hjl at lucon dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: ia64-unknown-linux-gnu
  GCC host triplet: ia64-unknown-linux-gnu
GCC target triplet: ia64-unknown-linux-gnu


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


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

* [Bug target/16559] Incorrect code generated for function pointer
  2004-07-15  7:04 [Bug target/16559] New: Incorrect code generated for function pointer hjl at lucon dot org
@ 2004-07-15  7:07 ` hjl at lucon dot org
  2004-07-15  7:10 ` pinskia at gcc dot gnu dot org
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: hjl at lucon dot org @ 2004-07-15  7:07 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From hjl at lucon dot org  2004-07-15 07:07 -------
Created an attachment (id=6750)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=6750&action=view)
A testcase

[hjl@gnu-4 fptr]$ make
gcc -g -O2   -c -o simple.o simple.c
gcc  -o simple simple.o
./simple
GP: 0x84000880100000
nm simple | grep _GLOBAL_OFFSET_TABLE_
6000000000000cd8 G _GLOBAL_OFFSET_TABLE_

GP should be the same as _GLOBAL_OFFSET_TABLE_. If I change

  for (i = 0; i < 1; i++)
    printf ("GP: 0x%lx\n", FDESC_GP(os_boot_rendez));

to

  printf ("GP: 0x%lx\n", FDESC_GP(os_boot_rendez));

it works OK.


-- 


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


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

* [Bug target/16559] Incorrect code generated for function pointer
  2004-07-15  7:04 [Bug target/16559] New: Incorrect code generated for function pointer hjl at lucon dot org
  2004-07-15  7:07 ` [Bug target/16559] " hjl at lucon dot org
@ 2004-07-15  7:10 ` pinskia at gcc dot gnu dot org
  2004-07-15  7:18 ` hjl at lucon dot org
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-15  7:10 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-07-15 07:10 -------
(struct ia64_fdesc *) fn is undefined C.

-- 


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


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

* [Bug target/16559] Incorrect code generated for function pointer
  2004-07-15  7:04 [Bug target/16559] New: Incorrect code generated for function pointer hjl at lucon dot org
  2004-07-15  7:07 ` [Bug target/16559] " hjl at lucon dot org
  2004-07-15  7:10 ` pinskia at gcc dot gnu dot org
@ 2004-07-15  7:18 ` hjl at lucon dot org
  2004-07-15 18:38 ` arun dot sharma at intel dot com
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: hjl at lucon dot org @ 2004-07-15  7:18 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From hjl at lucon dot org  2004-07-15 07:18 -------
This should work on ia64. Otherwise, we will be in big trouble. The issue is
we can never access a function pointer with

        addl r14 = @ltoffx(os_boot_rendez#), r1
        ...
        ld8.mov r14 = [r14], os_boot_rendez#

This sequence is for accessing data. A function pointer has to be accessed
with special relocations like

        addl r14 = @ltoff(@fptr(os_boot_rendez#)), gp

BTW, gcc 3.4 is OK.

-- 


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


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

* [Bug target/16559] Incorrect code generated for function pointer
  2004-07-15  7:04 [Bug target/16559] New: Incorrect code generated for function pointer hjl at lucon dot org
                   ` (2 preceding siblings ...)
  2004-07-15  7:18 ` hjl at lucon dot org
@ 2004-07-15 18:38 ` arun dot sharma at intel dot com
  2004-07-16  0:26 ` wilson at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: arun dot sharma at intel dot com @ 2004-07-15 18:38 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |arun dot sharma at intel dot
                   |                            |com


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


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

* [Bug target/16559] Incorrect code generated for function pointer
  2004-07-15  7:04 [Bug target/16559] New: Incorrect code generated for function pointer hjl at lucon dot org
                   ` (3 preceding siblings ...)
  2004-07-15 18:38 ` arun dot sharma at intel dot com
@ 2004-07-16  0:26 ` wilson at gcc dot gnu dot org
  2004-07-16  0:52 ` hjl at lucon dot org
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: wilson at gcc dot gnu dot org @ 2004-07-16  0:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From wilson at gcc dot gnu dot org  2004-07-16 00:26 -------
This is only partly fixed in gcc-3.4/mainline.  If you use an offset larger than
the 14-bit immediate field, then it still fails.  You can see this if you add a
field to the structure
  unsigned int array[2048];
and then look at the resulting assembly.  However, I think we can ignore this
indefinitely, as the function descriptors are only 16-bytes long, and hence we
don't need such large offsets to work.

The patch that fixed it on mainline is the second patch in
    http://gcc.gnu.org/ml/gcc-patches/2003-05/msg01325.html
Unfortunately, this depends on other patches, and fixes other problems, so we
probably don't want to bring the whole thing in.  We really only need one line
of it though.

The underlying problem here is that ia64_expand_load_address knows that certain
kinds of SYMBOL_REFs have to be treated specially, but it gives no special
treatment to a SYMBOL_REF that is inside a CONST.  The above patch fixes this by
replacing a call to gen_load_symptr with a recursive call.  This only partly
solves the problem though, because if hi != 0, then we have another CONST, and
the special bits on the SYMBOL_REF get ignored again.  This is good enough to
make this testcase work though.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |wilson at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-07-16 00:26:21
               date|                            |


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


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

* [Bug target/16559] Incorrect code generated for function pointer
  2004-07-15  7:04 [Bug target/16559] New: Incorrect code generated for function pointer hjl at lucon dot org
                   ` (4 preceding siblings ...)
  2004-07-16  0:26 ` wilson at gcc dot gnu dot org
@ 2004-07-16  0:52 ` hjl at lucon dot org
  2004-07-16  1:11 ` wilson at specifixinc dot com
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: hjl at lucon dot org @ 2004-07-16  0:52 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From hjl at lucon dot org  2004-07-16 00:52 -------
I agree we can ignore large offset if we don't want to spend time on it. What does
gcc do with large offset? Does it generate wrong code or abort? My test shows
that gcc 3.4 generates wrong code with large offset. I think it should abort.


-- 


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


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

* [Bug target/16559] Incorrect code generated for function pointer
  2004-07-15  7:04 [Bug target/16559] New: Incorrect code generated for function pointer hjl at lucon dot org
                   ` (5 preceding siblings ...)
  2004-07-16  0:52 ` hjl at lucon dot org
@ 2004-07-16  1:11 ` wilson at specifixinc dot com
  2004-07-20  5:25 ` hjl at lucon dot org
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: wilson at specifixinc dot com @ 2004-07-16  1:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From wilson at specifixinc dot com  2004-07-16 01:11 -------
Subject: Re:  Incorrect code generated for function pointer

On Thu, 2004-07-15 at 17:52, hjl at lucon dot org wrote:
> I agree we can ignore large offset if we don't want to spend time on it. What does
> gcc do with large offset? Does it generate wrong code or abort? My test shows
> that gcc 3.4 generates wrong code with large offset. I think it should abort.

Yes, we generate wrong code, but then this isn't valid C code, and this
code has no possible use, so I don't see any reason to worry about it. 
At least not for the gcc-3.3 or gcc-3.4 releases.  It might be
reasonable to do something on mainline.  It wouldn't be hard to add a
few checks for special SYMBOL_REFs and call abort if they weren't
handled right.


-- 


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


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

* [Bug target/16559] Incorrect code generated for function pointer
  2004-07-15  7:04 [Bug target/16559] New: Incorrect code generated for function pointer hjl at lucon dot org
                   ` (6 preceding siblings ...)
  2004-07-16  1:11 ` wilson at specifixinc dot com
@ 2004-07-20  5:25 ` hjl at lucon dot org
  2004-07-20  5:45 ` hjl at lucon dot org
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: hjl at lucon dot org @ 2004-07-20  5:25 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From hjl at lucon dot org  2004-07-20 05:25 -------
Jim, I applied to your patch to gcc 3.3. Here is the result:

http://gcc.gnu.org/ml/gcc-testresults/2004-07/msg00884.html

-- 


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


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

* [Bug target/16559] Incorrect code generated for function pointer
  2004-07-15  7:04 [Bug target/16559] New: Incorrect code generated for function pointer hjl at lucon dot org
                   ` (7 preceding siblings ...)
  2004-07-20  5:25 ` hjl at lucon dot org
@ 2004-07-20  5:45 ` hjl at lucon dot org
  2004-07-21  1:42 ` wilson at specifixinc dot com
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: hjl at lucon dot org @ 2004-07-20  5:45 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From hjl at lucon dot org  2004-07-20 05:45 -------
A testcase patch is posted at

http://gcc.gnu.org/ml/gcc-patches/2004-07/msg01896.html

-- 


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


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

* [Bug target/16559] Incorrect code generated for function pointer
  2004-07-15  7:04 [Bug target/16559] New: Incorrect code generated for function pointer hjl at lucon dot org
                   ` (8 preceding siblings ...)
  2004-07-20  5:45 ` hjl at lucon dot org
@ 2004-07-21  1:42 ` wilson at specifixinc dot com
  2004-07-21  2:36 ` cvs-commit at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: wilson at specifixinc dot com @ 2004-07-21  1:42 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From wilson at specifixinc dot com  2004-07-21 01:42 -------
Subject: Re:  Incorrect code generated for function pointer

On Mon, 2004-07-19 at 22:25, hjl at lucon dot org wrote:
> Jim, I applied to your patch to gcc 3.3. Here is the result:
> http://gcc.gnu.org/ml/gcc-testresults/2004-07/msg00884.html

I did my own testing over the weekend.  I did a build of gcc-3.3 with
and without the patch, and ran the testsuites for both.  There were no
regressions.

I verified today that this is a regression from gcc-2.96.

So I think all we need is permission from Gaby, as I am not sure if I
can apply a patch to the gcc-3.3.x release branch without his
permission.  I will send the patch off to gcc-patches and cc him to get
his comments.


-- 


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


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

* [Bug target/16559] Incorrect code generated for function pointer
  2004-07-15  7:04 [Bug target/16559] New: Incorrect code generated for function pointer hjl at lucon dot org
                   ` (9 preceding siblings ...)
  2004-07-21  1:42 ` wilson at specifixinc dot com
@ 2004-07-21  2:36 ` cvs-commit at gcc dot gnu dot org
  2004-07-23 19:45 ` cvs-commit at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-07-21  2:36 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-07-21 02:35 -------
Subject: Bug 16559

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	hjl@gcc.gnu.org	2004-07-21 02:35:56

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg: ia64-fptr-1.c 

Log message:
	2004-07-20  H.J. Lu  <hongjiu.lu@intel.com>
	
	PR target/16559
	* gcc.dg/ia64-fptr-1.c: New file.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4028&r2=1.4029
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/ia64-fptr-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1



-- 


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


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

* [Bug target/16559] Incorrect code generated for function pointer
  2004-07-15  7:04 [Bug target/16559] New: Incorrect code generated for function pointer hjl at lucon dot org
                   ` (10 preceding siblings ...)
  2004-07-21  2:36 ` cvs-commit at gcc dot gnu dot org
@ 2004-07-23 19:45 ` cvs-commit at gcc dot gnu dot org
  2004-07-23 20:17 ` wilson at gcc dot gnu dot org
  2004-07-30 19:38 ` pinskia at gcc dot gnu dot org
  13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-07-23 19:45 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-07-23 19:45 -------
Subject: Bug 16559

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	wilson@gcc.gnu.org	2004-07-23 19:44:59

Modified files:
	gcc            : ChangeLog 
	gcc/config/ia64: ia64.c 

Log message:
	Fix problem with addressing function descriptors.
	PR target/16559
	* ia64.c (ia64_expand_load_address): For CONST, replace
	gen_load_symptr call with recursive call.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.1002&r2=1.16114.2.1003
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/ia64/ia64.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.198.2.20&r2=1.198.2.21



-- 


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


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

* [Bug target/16559] Incorrect code generated for function pointer
  2004-07-15  7:04 [Bug target/16559] New: Incorrect code generated for function pointer hjl at lucon dot org
                   ` (11 preceding siblings ...)
  2004-07-23 19:45 ` cvs-commit at gcc dot gnu dot org
@ 2004-07-23 20:17 ` wilson at gcc dot gnu dot org
  2004-07-30 19:38 ` pinskia at gcc dot gnu dot org
  13 siblings, 0 replies; 15+ messages in thread
From: wilson at gcc dot gnu dot org @ 2004-07-23 20:17 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From wilson at gcc dot gnu dot org  2004-07-23 20:17 -------
Fixed.

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


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


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

* [Bug target/16559] Incorrect code generated for function pointer
  2004-07-15  7:04 [Bug target/16559] New: Incorrect code generated for function pointer hjl at lucon dot org
                   ` (12 preceding siblings ...)
  2004-07-23 20:17 ` wilson at gcc dot gnu dot org
@ 2004-07-30 19:38 ` pinskia at gcc dot gnu dot org
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-30 19:38 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |3.3.5


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


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

end of thread, other threads:[~2004-07-30 19:37 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-15  7:04 [Bug target/16559] New: Incorrect code generated for function pointer hjl at lucon dot org
2004-07-15  7:07 ` [Bug target/16559] " hjl at lucon dot org
2004-07-15  7:10 ` pinskia at gcc dot gnu dot org
2004-07-15  7:18 ` hjl at lucon dot org
2004-07-15 18:38 ` arun dot sharma at intel dot com
2004-07-16  0:26 ` wilson at gcc dot gnu dot org
2004-07-16  0:52 ` hjl at lucon dot org
2004-07-16  1:11 ` wilson at specifixinc dot com
2004-07-20  5:25 ` hjl at lucon dot org
2004-07-20  5:45 ` hjl at lucon dot org
2004-07-21  1:42 ` wilson at specifixinc dot com
2004-07-21  2:36 ` cvs-commit at gcc dot gnu dot org
2004-07-23 19:45 ` cvs-commit at gcc dot gnu dot org
2004-07-23 20:17 ` wilson at gcc dot gnu dot org
2004-07-30 19:38 ` pinskia at gcc dot gnu dot 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).