This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] i386 bad relative call
- To: gcc-patches at gcc dot gnu dot org
- Subject: [patch] i386 bad relative call
- From: Clinton Popetz <cpopetz at cygnus dot com>
- Date: Wed, 1 Mar 2000 11:45:13 -0600
The following code:
void (*ptr)(void);
void foo(void)
{
if( (int)ptr== 0x12800000 )
{
ptr();
}
}
at >=O1 will emit a
call 310378496
which will be interpreted as a relative call by the assembler. This was a
problem partially fixed by:
Mon Sep 13 15:21:46 1999 Richard Henderson <rth@cygnus.com>
* i386.c (call_insn_operand): Reject const_int.
(expander_call_insn_operand): Use call_insn_operand.
but in this case cse is substituting the constant.
-Clint
2000-03-01 Clinton Popetz <cpopetz@cygnus.com>
* config/i386/i386.c: (constant_call_address_operand): Reject
CONST_INT.
Index: config/i386/i386.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/i386.c,v
retrieving revision 1.140
diff -c -2 -p -r1.140 i386.c
*** i386.c 2000/02/26 21:44:41 1.140
--- i386.c 2000/03/01 17:37:39
*************** constant_call_address_operand (op, mode)
*** 1089,1093 ****
enum machine_mode mode ATTRIBUTE_UNUSED;
{
! return GET_CODE (op) == MEM && CONSTANT_ADDRESS_P (XEXP (op, 0));
}
--- 1089,1095 ----
enum machine_mode mode ATTRIBUTE_UNUSED;
{
! return GET_CODE (op) == MEM &&
! CONSTANT_ADDRESS_P (XEXP (op, 0)) &&
! GET_CODE (XEXP (op, 0)) != CONST_INT;
}