This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Segfault in rtx_varies_p

Paul Brook wrote:

When complied with -O2 on arm-none-elf, the following testcase causes a segfault.

static const char digs[] = "0123456789ABCDEF";
int __attribute__((pure)) bar();

int foo (int i)
 int len;
 if (i)
   return 0;
 len = bar();
 return digs[len];

For the call to bar() we generate a libcall sequence. This includes a REG_EQUAL note containing a EXPR_LIST of the parameters of the libcall (and symbol for bar).

(insn (set (reg 101) (...))
	(insn_list:REG_RETVAL ...
	(expr_list:REG_EQUAL (expr_list (use (mem:blk scratch))
					(expr_list (symbol_ref "bar")
(insn (set (reg 102) (symbol_ref "digs)))
(insn (set (reg 103) (mem (plus (reg 101) (reg 102))))
	(expr_list:REG_EQUAL (plus (reg 101) (symbol_ref "bar")))

This last REG_EQUAL note doesn't look right to me.

It references "bar", rather than "digs". Why is that?

During the gcse pass we then propagate the equality for reg101 from the first REG_EQUAL note into the second REG_EQUAL note (the code for for digs[len]). In a later pass rtx_varies_p falls over on the NULL terminator of the EXPR_LIST.

Jeff, Richard: do y'all have thoughts about this?

Mark Mitchell
CodeSourcery, LLC
(916) 791-8304

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]