[PATCH 1/5] x86: Add -mindirect-branch=

H.J. Lu hjl.tools@gmail.com
Sun Jan 14 12:53:00 GMT 2018


On Sun, Jan 14, 2018 at 3:06 AM, Jan Hubicka <hubicka@ucw.cz> wrote:
>> On 2018.01.14 at 11:46 +0100, Jan Hubicka wrote:
>> > > gcc/
>> > >
>> > >   * config/i386/i386-opts.h (indirect_branch): New.
>> > >   * config/i386/i386-protos.h (ix86_output_indirect_jmp): Likewise.
>> > >   * config/i386/i386.c (ix86_using_red_zone): Disallow red-zone
>> > >   with local indirect jump when converting indirect call and jump.
>> > >   (ix86_set_indirect_branch_type): New.
>> > >   (ix86_set_current_function): Call ix86_set_indirect_branch_type.
>> > >   (indirectlabelno): New.
>> > >   (indirect_thunk_needed): Likewise.
>> > >   (indirect_thunk_bnd_needed): Likewise.
>> > >   (indirect_thunks_used): Likewise.
>> > >   (indirect_thunks_bnd_used): Likewise.
>> > >   (INDIRECT_LABEL): Likewise.
>> > >   (indirect_thunk_name): Likewise.
>> > >   (output_indirect_thunk): Likewise.
>> > >   (output_indirect_thunk_function): Likewise.
>> > >   (ix86_output_indirect_branch): Likewise.
>> > >   (ix86_output_indirect_jmp): Likewise.
>> > >   (ix86_code_end): Call output_indirect_thunk_function if needed.
>> > >   (ix86_output_call_insn): Call ix86_output_indirect_branch if
>> > >   needed.
>> > >   (ix86_handle_fndecl_attribute): Handle indirect_branch.
>> > >   (ix86_attribute_table): Add indirect_branch.
>> > >   * config/i386/i386.h (machine_function): Add indirect_branch_type
>> > >   and has_local_indirect_jump.
>> > >   * config/i386/i386.md (indirect_jump): Set has_local_indirect_jump
>> > >   to true.
>> > >   (tablejump): Likewise.
>> > >   (*indirect_jump): Use ix86_output_indirect_jmp.
>> > >   (*tablejump_1): Likewise.
>> > >   (simple_return_indirect_internal): Likewise.
>> > >   * config/i386/i386.opt (mindirect-branch=): New option.
>> > >   (indirect_branch): New.
>> > >   (keep): Likewise.
>> > >   (thunk): Likewise.
>> > >   (thunk-inline): Likewise.
>> > >   (thunk-extern): Likewise.
>> > >   * doc/extend.texi: Document indirect_branch function attribute.
>> > >   * doc/invoke.texi: Document -mindirect-branch= option.
>> > > +
>> > > +  /* Pause .  */
>> > > +  fprintf (asm_out_file, "\tpause\n");
>> >
>> > OK, but please prepare incremental patches to choose between pause and lefence
>> > as needed for AMD CPUs and check for large code model.
>>
>> Why not use both? That would make everybody happy, no?
>>
>>  pause
>>  lfence
>>  jmp
>
> Yes, according to my understanding we want both pause and lefence by default
> (it is expensive anyway) + command line option to control which one to use?
>
> Probably thus the first patch should default to both.

Done.  This is the patch I am checking in.

-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-x86-Add-mindirect-branch.patch
Type: text/x-patch
Size: 72825 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20180114/f7c57ab7/attachment.bin>


More information about the Gcc-patches mailing list