[PATCH] [PR target/96350]Force ENDBR immediate into memory to avoid fake ENDBR opcode.

Hongtao Liu crazylht@gmail.com
Tue Aug 11 09:36:24 GMT 2020


On Tue, Aug 11, 2020 at 4:38 PM Uros Bizjak <ubizjak@gmail.com> wrote:
>
> On Tue, Aug 11, 2020 at 5:30 AM Hongtao Liu <crazylht@gmail.com> wrote:
> >
> > Hi:
> >   The issue is described in the bugzilla.
> >   Bootstrap is ok, regression test for i386/x86-64 backend is ok.
> >   Ok for trunk?
> >
> > ChangeLog
> > gcc/
> >         PR target/96350
> >         * config/i386/i386.c (ix86_legitimate_constant_p): Return
> >         false for ENDBR immediate.
> >         (ix86_legitimate_address_p): Ditto.
> >         * config/i386/predicated.md
> >         (x86_64_immediate_operand): Exclude ENDBR immediate.
> >         (x86_64_zext_immediate_operand): Ditto.
> >         (x86_64_dwzext_immediate_operand): Ditto.
> >         (ix86_not_endbr_immediate_operand): New predicate.
> >
> > gcc/testsuite
> >         * gcc.target/i386/endbr_immediate.c: New test.
>
> +;; Return true if VALUE isn't an ENDBR opcode in immediate field.
> +(define_predicate "ix86_not_endbr_immediate_operand"
> +  (match_test "1")
>
> Please reverse the above logic to introduce
> ix86_endbr_immediate_operand, that returns true for unwanted
> immediate. Something like:
>
> (define_predicate "ix86_endbr_immediate_operand"
>   (match_code "const_int")
> ...
>
> And you will be able to use it like:
>
> if (ix86_endbr_immediate_operand (x, VOIDmode)
>   return false;
>

Changed.

>    /* Otherwise we handle everything else in the move patterns.  */
> -  return true;
> +  return ix86_not_endbr_immediate_operand (x, VOIDmode);
>  }
>
> Please handle this in CASE_CONST_SCALAR_INT: part.
>
> +  if (disp && !ix86_not_endbr_immediate_operand (disp, VOIDmode))
> +    return false;
>
> And this in:
>
>   /* Validate displacement.  */
>   if (disp)
>     {
>

Changed.

> Uros.
>
> > --
> > BR,
> > Hongtao

Update patch.

-- 
BR,
Hongtao
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Force-ENDBR-immediate-into-memory_v2.patch
Type: text/x-patch
Size: 6381 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20200811/bb8afb2c/attachment-0001.bin>


More information about the Gcc-patches mailing list