This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
gcc 3.3.1 segmentation fault (in rtlanal.c, rtx_varies_p())
- From: Grigory Tolstolytkin <gtolstolytkin at dev dot rtsoft dot ru>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 26 Aug 2004 18:50:08 +0400
- Subject: gcc 3.3.1 segmentation fault (in rtlanal.c, rtx_varies_p())
When compiling attached source file, the compiler crashes with
segmentation fault in rtx_varies_p() function in rtlanal.c
I reproduced it at least for two tragets: arm_v5t_le and arm_iwmmxt_le.
It doesn't occur when compiling with -O0 or -O1,
but for others do.
I debugged the compiler and found that the compiler generates the
following rtl instruction:
(insn 16 15 17 0 0x4021b344 (set (reg/f:SI 71)
(reg:SI 0 r0)) 345 {*iwmmxt_movsi_insn} (nil)
(insn_list:REG_RETVAL 15 (expr_list:REG_EQUAL (expr_list
(symbol_ref:SI ("cl"))
(nil))
(nil))))
Then, the "expr_list (symbol_ref:SI("cl"))" comes to the hash table for
CSE optimization (the hash table declared in cse.c)
And when CSE optimization is applied
(cse_insn() is called on the rtl instruction
(insn 28 47 36 1 0x4021b318 (set (mem/f:SI (plus:SI (reg/f:SI 25 sfp)
(const_int -4 [0xfffffffc])) [2 S4 A32])
(reg/v/f:SI 68)) 345 {*iwmmxt_movsi_insn} (nil)
(nil))
) the rtl expression from the hash table is extracted and rtx_varies_p()
function is called on each parameter of expr_list.
But the second parameter is NIL and rtx_varies_p() crashes on the first
line (code = GET_CODE(x)), since the x is NULL.
If I add the follwing code in the beginning of rtx_varies_p():
"
if (x == NULL)
return 0; // nil expression doesn't have have a value which
can vary even between two executions of the program
"
then the compiler successfully generates object file. I wrote a simple
test which calls the code from that object file and everything seems to
work fine.
But I suppose that my fix might be wrong since I don't clearly
understand how the compiler should work. In fact, does anybody know
whether it's possible that such expressions may occur in the hash table
or not?
Compilation parameters:
'arm_v5t_le-gcc -Os -c test.c -o test.o'
Any help is appreciated.
struct st
{
int ia[256];
unsigned char uc;
};
extern struct st *cl(void) __attribute__ ((__const__));
extern void bar(int **);
void foo(int *f, __builtin_va_list arg)
{
if (((*cl()).uc) != 1) {
int *p = f;
bar(&p);
}
}