public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: "H.J. Lu" <hjl.tools@gmail.com>, Uros Bizjak <ubizjak@gmail.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>, Jan Hubicka <hubicka@ucw.cz>
Subject: Re: [PATCH] i386; Add indirect_return function attribute
Date: Wed, 04 Jul 2018 02:36:00 -0000	[thread overview]
Message-ID: <b7b7fac5-1aad-0ce5-5ff9-436dd93b9440@redhat.com> (raw)
In-Reply-To: <CAMe9rOrdOO=sBStLP6r8HdJNkNb1PvywFX_1-NLw4qqXMH-4DQ@mail.gmail.com>

On 07/03/2018 10:53 AM, H.J. Lu wrote:
> On Tue, Jul 3, 2018 at 9:12 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
>> On Tue, Jul 3, 2018 at 5:32 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>> On Fri, Jun 8, 2018 at 3:27 AM, H.J. Lu <hongjiu.lu@intel.com> wrote:
>>>> On x86, swapcontext may return via indirect branch when shadow stack
>>>> is enabled.  To support code instrumentation of control-flow transfers
>>>> with -fcf-protection, add indirect_return function attribute to inform
>>>> compiler that a function may return via indirect branch.
>>>>
>>>> Note: Unlike setjmp, swapcontext only returns once.  Mark it return
>>>> twice will unnecessarily disable compiler optimization.
>>>>
>>>> OK for trunk?
>>>>
>>>> H.J.
>>>> ----
>>>> gcc/
>>>>
>>>>         PR target/85620
>>>>         * config/i386/i386.c (rest_of_insert_endbranch): Also generate
>>>>         ENDBRANCH for non-tail call which may return via indirect branch.
>>>>         * doc/extend.texi: Document indirect_return attribute.
>>>>
>>>> gcc/testsuite/
>>>>
>>>>         PR target/85620
>>>>         * gcc.target/i386/pr85620-1.c: New test.
>>>>         * gcc.target/i386/pr85620-2.c: Likewise.
>>>>
>>> Here is the updated patch with a testcase to show the impact of
>>> returns_twice attribute.
>>>
>>> Jan, Uros, can you take a look?
>> LGTM for the implementation, can't say if attribute is really needed or not.
> This gives programmers more flexibly.
> 
>> +@item indirect_return
>> +@cindex @code{indirect_return} function attribute, x86
>> +
>> +The @code{indirect_return} attribute on a function is used to inform
>> +the compiler that the function may return via indiret branch.
>>
>> s/indiret/indirect/
> Fixed.  Here is the updated patch.
> 
> Thanks.
> 
> -- H.J.
> 
> 
> 0001-i386-Add-indirect_return-function-attribute.patch
> 
> 
> From bb98f6a31801659ae3c6689d6d31af33a3c28bb2 Mon Sep 17 00:00:00 2001
> From: "H.J. Lu" <hjl.tools@gmail.com>
> Date: Thu, 7 Jun 2018 20:05:15 -0700
> Subject: [PATCH] i386; Add indirect_return function attribute
> 
> On x86, swapcontext may return via indirect branch when shadow stack
> is enabled.  To support code instrumentation of control-flow transfers
> with -fcf-protection, add indirect_return function attribute to inform
> compiler that a function may return via indirect branch.
> 
> Note: Unlike setjmp, swapcontext only returns once.  Mark it return
> twice will unnecessarily disable compiler optimization as shown in
> the testcase here.
> 
> gcc/
> 
> 	PR target/85620
> 	* config/i386/i386.c (rest_of_insert_endbranch): Also generate
> 	ENDBRANCH for non-tail call which may return via indirect branch.
> 	* doc/extend.texi: Document indirect_return attribute.
OK
jeff

      reply	other threads:[~2018-07-04  2:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-08 10:27 H.J. Lu
2018-07-03 15:32 ` H.J. Lu
2018-07-03 16:12   ` Uros Bizjak
2018-07-03 16:53     ` H.J. Lu
2018-07-04  2:36       ` Jeff Law [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b7b7fac5-1aad-0ce5-5ff9-436dd93b9440@redhat.com \
    --to=law@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hjl.tools@gmail.com \
    --cc=hubicka@ucw.cz \
    --cc=ubizjak@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).