This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PING^3: [PATCH] i386: Don't generate alias for function return thunk


On Thu, Mar 15, 2018 at 8:51 AM, Jan Hubicka <hubicka@ucw.cz> wrote:
>> On Sun, Mar 11, 2018 at 7:39 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> > On Mon, Mar 5, 2018 at 4:17 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> >> On Mon, Feb 26, 2018 at 12:48 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
>> >>> Function return thunks shouldn't be aliased to indirect branch thunks
>> >>> since indirect branch thunks are placed in COMDAT section and a COMDAT
>> >>> section with indirect branch may not have function return thunk.  This
>> >>> patch generates function return thunks directly.
>> >>>
>> >>> Tested on i686 and x86-64.  OK for trunk?
>> >>>
>> >>> H.J.
>> >>> ---
>> >>> gcc/
>> >>>
>> >>>         PR target/84574
>> >>>         * config/i386/i386.c (indirect_thunk_needed): Update comments.
>> >>>         (indirect_thunk_bnd_needed): Likewise.
>> >>>         (indirect_thunks_used): Likewise.
>> >>>         (indirect_thunks_bnd_used): Likewise.
>> >>>         (indirect_return_needed): New.
>> >>>         (indirect_return_bnd_needed): Likewise.
>> >>>         (output_indirect_thunk_function): Add a bool argument for
>> >>>         function return.
>> >>>         (output_indirect_thunk_function): Don't generate alias for
>> >>>         function return thunk.
>> >>>         (ix86_code_end): Call output_indirect_thunk_function to generate
>> >>>         function return thunks.
>> >>>         (ix86_output_function_return): Set indirect_return_bnd_needed
>> >>>         and indirect_return_needed instead of indirect_thunk_bnd_needed
>> >>>         and indirect_thunk_needed.
>> >>>
>> >>> gcc/testsuite/
>> >>>
>> >>>         PR target/84574
>> >>>         * gcc.target/i386/ret-thunk-9.c: Expect __x86_return_thunk
>> >>>         label instead of __x86_indirect_thunk label.
>> >>
>
> So problem here is that you may output the comdat without return thunk from one unit
> and with return thunk with different unit and comdat merging will then render return thunk
> unreachable?

Yes.  return thunk becomes undefined.

> What is the reason for using different names for return and indirect thunks at first place?
>

These 2 thunks are identical.  But one may want to provide an
alternate thunk only for
indirect branch and leaves return thunk alone.  You can't do that if
both have the same
name.

-- 
H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]