On Wed, Nov 12, 2014 at 9:43 PM, H.J. Lu <hongjiu...@intel.com> wrote:
> Hi,
>
> r216154 exposed an x86 backend bug.  For large PIC mode thunk, there
> are
>
>       if (ix86_cmodel == CM_LARGE_PIC && SYMBOLIC_CONST (fnaddr))
>         fnaddr = legitimize_pic_address (fnaddr,
>                                          gen_rtx_REG (Pmode, tmp_regno));
>
> and legitimize_pic_address does:
>
>       if (reg != 0)
>         {
>           new_rtx = expand_simple_binop (Pmode, PLUS, reg, 
> pic_offset_table_rtx,
>                                          tmpreg, 1, OPTAB_DIRECT);
>           new_rtx = reg;
>         }
>
> However, pic_offset_table_rtx was never initialized.  Befor r216154,
> we generated thunk with random value in hardcoded PIC register.  After
> r216154, compiler crashes.  This patch sets PIC register to %r11 and
> initialize it.  Tested on Linux/x86-64.  OK for trunk and backport
> to 4.8/4.9 branches?
>
> 2014-11-12  H.J. Lu  <hongjiu...@intel.com>
>
>         PR target/63815
>         * config/i386/i386.c (ix86_init_large_pic_reg): New.  Extracted
>         from ...
>         (ix86_init_pic_reg): Here.  Use ix86_init_large_pic_reg.
>         (x86_output_mi_thunk): Set PIC register to %r11.  Call
>         ix86_init_large_pic_reg to initialize PIC register.
>
> gcc/testsuite/
>
> 2014-11-12  H.J. Lu  <hongjiu...@intel.com>
>
>         PR target/63815
>         * g++.dg/other/pr63815.C: New test.

OK for mainline with a short comment addition.

Backports to release branches need RM's approval.

Thanks,
Uros.

>        if (ix86_cmodel == CM_LARGE_PIC && SYMBOLIC_CONST (fnaddr))
> -       fnaddr = legitimize_pic_address (fnaddr,
> -                                        gen_rtx_REG (Pmode, tmp_regno));
> +       {

Please put a short comment why we need hard reg here.

> +         SET_REGNO (pic_offset_table_rtx, R11_REG);

Reply via email to