On Tue, May 21, 2019 at 11:48 PM H.J. Lu <hjl.to...@gmail.com> wrote:
>
> On Sat, Feb 16, 2019 at 7:02 AM H.J. Lu <hjl.to...@gmail.com> wrote:
> >
> > On Thu, Feb 14, 2019 at 08:13:32PM -0800, H.J. Lu wrote:
> > > NOTE_INSN_DELETED_LABEL is used to mark what used to be a 'code_label',
> > > but was not used for other purposes than taking its address and was
> > > transformed to mark that no code jumps to it.  NOTE_INSN_DELETED_LABEL
> > > is generated only in 3 places:
> > >
> > > 1. When delete_insn sees an unused label which is an explicit label in
> > > the input source code or its address is taken, it turns the label into
> > > a NOTE_INSN_DELETED_LABEL note.
> > > 2. When rtl_tidy_fallthru_edge deletes a tablejump, it turns the
> > > tablejump into a NOTE_INSN_DELETED_LABEL note.
> > > 3. ix86_init_large_pic_reg creats a NOTE_INSN_DELETED_LABEL note, .L2,
> > > to initialize large model PIC register:
> > >
> > > L2:
> > >       movabsq $_GLOBAL_OFFSET_TABLE_-.L2, %r11
> > >       leaq    .L2(%rip), %rax
> > >       movabsq $val@GOT, %rdx
> > >       addq    %r11, %rax
> > >
> > > Among of them, ENDBR is needed only when the label address is taken.
> > > rest_of_insert_endbranch has
> > >
> > >           if ((LABEL_P (insn) && LABEL_PRESERVE_P (insn))
> > >               || (NOTE_P (insn)
> > >                   && NOTE_KIND (insn) == NOTE_INSN_DELETED_LABEL))
> > >             /* TODO.  Check /s bit also.  */
> > >             {
> > >               cet_eb = gen_nop_endbr ();
> > >               emit_insn_after (cet_eb, insn);
> > >               continue;
> > >             }
> > >
> > > For NOTE_INSN_DELETED_LABEL, we should check if forced_labels to see
> > > if its address is taken.  Also ix86_init_large_pic_reg shouldn't set
> > > LABEL_PRESERVE_P (in_struct) since NOTE_INSN_DELETED_LABEL is suffcient
> > > to keep the label.
> > >
> > > gcc/
> > >
> > >       PR target/89355
> > >       * config/i386/i386.c (rest_of_insert_endbranch): Check
> > >       forced_labels to see if the address of NOTE_INSN_DELETED_LABEL
> > >       is taken.
> > >       (ix86_init_large_pic_reg): Don't set LABEL_PRESERVE_P.
> > >
> >
> > Here is the updated patch.  We should check LABEL_PRESERVE_P on
> > NOTE_INSN_DELETED_LABEL to see if its address is taken.
> >
> > OK for trunk?
> >
> > Thanks.
> >
> > H.J.
> > ---
> > NOTE_INSN_DELETED_LABEL is used to mark what used to be a 'code_label',
> > but was not used for other purposes than taking its address and was
> > transformed to mark that no code jumps to it.  Since LABEL_PRESERVE_P is
> > true only if the label address was taken, check LABEL_PRESERVE_P before
> > inserting ENDBR.
> >
> > 2019-02-15  H.J. Lu  <hongjiu...@intel.com>
> >             Hongtao Liu  <hongtao....@intel.com>
> >
> > gcc/
> >
> >         PR target/89355
> >         * config/i386/i386.c (rest_of_insert_endbranch): LABEL_PRESERVE_P
> >         to see if the address of NOTE_INSN_DELETED_LABEL is taken.
> >         (ix86_init_large_pic_reg): Don't set LABEL_PRESERVE_P.
> >
> > gcc/testsuite/
> >
> >         PR target/89355
> >         * gcc.target/i386/cet-label-3.c: New test.
> >         * gcc.target/i386/cet-label-4.c: Likewise.
> >         * gcc.target/i386/cet-label-5.c: Likewise.
>
> PING:
>
> https://gcc.gnu.org/ml/gcc-patches/2019-02/msg01327.html

This patch goes deep into RTL details, so IMO RTL expert (Jeff ?)
should approve it.

Uros.

Reply via email to