Question about ASMCONS

Claudiu Zissulescu claziss@gmail.com
Mon Dec 19 18:59:00 GMT 2016


On 19/12/2016 18:06, Segher Boessenkool wrote:
> Hi Claudiu,
>
> On Mon, Dec 19, 2016 at 12:28:54PM +0000, Claudiu Zissulescu wrote:
>> I have the following rtl before asmcons pass:
>>
>> (insn 8 13 9 2 (set (reg:SI 157 [ list ])
>>         (asm_operands:SI ("") ("=g") 0 [
>>                 (const:SI (unspec:SI [
>>                             (symbol_ref:SI ("c_const") [flags 0x2]  <var_decl 0x7f6735ad25a0 c_const>)
>>                         ] ARC_UNSPEC_GOTOFFPC))
>>             ]
>>              [
>>                 (asm_input:SI ("0") ../t02.c:9)
>>             ]
>>              [] ../t02.c:9)) ../t02.c:9 -1
>>      (nil))
>
> [ snip ]
>
> asmcons eventual does reg_overlap_mentioned_p on the input of the move
> it created with an input of the asm.  The very first thing
> reg_overlap_mentioned_p tests for is if the thing is constant.  And it
> is here, and that makes no sense at all (since it is an output, too!)
>
> So how did that happen?
>
Right, the reg_overlap_mentioned_p returns zero letting the insn 8 
unchanged.
The problem is observed in crtstuff.c when compiling __do_globa_dtor_aux 
(line 398). Here it is a short test code:

typedef void (*func_ptr) (void);
static func_ptr __DTOR_LIST__[1] = { (func_ptr)(-1) };

void foo (int a)
{
   func_ptr *dtor_list;
   __asm ("" : "=g" (dtor_list) : "0" (__DTOR_LIST__));
   dtor_list[a]();
}

compiled with -O1 -fpic -mcpu=archs for ARC ;) it will crash somewhere 
in verify_rtx_sharing due to the duplicated const(unspec) thingy.

I was thinking to force the replacement of the input, in function.c:6781 
by adding to the condition an i == j check.

Due to this issue, the mainline cannot build ARC uClibc toolchain. I 
suspect that this issue may affect also mips or nios2, but not 100% sure.

Thanks,
Claudiu



More information about the Gcc mailing list