From: HAO CHEN GUI <guihaoc@linux.ibm.com>
To: Andrew Pinski <pinskia@gmail.com>
Cc: Richard Biener <richard.guenther@gmail.com>,
"Kewen.Lin" <linkw@linux.ibm.com>,
gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: Fwd: [PATCH, expand] Call misaligned memory reference in expand_builtin_return [PR112417]
Date: Mon, 13 Nov 2023 16:09:45 +0800 [thread overview]
Message-ID: <5cd48c76-a783-4577-8035-0ab922e32855@linux.ibm.com> (raw)
In-Reply-To: <e8bfd189-5c8b-4a1b-bc84-d3fe0cb1a032@linux.ibm.com>
Sorry, forgot to cc gcc-patches.
在 2023/11/13 16:05, HAO CHEN GUI 写道:
> Andrew,
> Could you kindly inform us what's the functionality of __objc_forward?
> Does it change the memory content pointed by args? Thanks a lot.
>
> Thanks
> Gui Haochen
>
>
> libobjc/sendmsg.c.
>
> void *args, *res;
>
> args = __builtin_apply_args ();
> res = __objc_forward (rcv, op, args);
> if (res)
> __builtin_return (res);
> else
> ...
>
> -------- 转发的消息 --------
> 主题: Re: [PATCH, expand] Call misaligned memory reference in expand_builtin_return [PR112417]
> 日期: Fri, 10 Nov 2023 14:39:02 +0100
> From: Richard Biener <richard.guenther@gmail.com>
> 收件人: HAO CHEN GUI <guihaoc@linux.ibm.com>
> 抄送: gcc-patches <gcc-patches@gcc.gnu.org>, Kewen.Lin <linkw@linux.ibm.com>
>
> On Fri, Nov 10, 2023 at 11:10 AM HAO CHEN GUI <guihaoc@linux.ibm.com> wrote:
>>
>> Hi Richard,
>>
>> 在 2023/11/10 17:06, Richard Biener 写道:
>>> On Fri, Nov 10, 2023 at 8:52 AM HAO CHEN GUI <guihaoc@linux.ibm.com> wrote:
>>>>
>>>> Hi Richard,
>>>> Thanks so much for your comments.
>>>>
>>>> 在 2023/11/9 19:41, Richard Biener 写道:
>>>>> I'm not sure if the testcase is valid though?
>>>>>
>>>>> @defbuiltin{{void} __builtin_return (void *@var{result})}
>>>>> This built-in function returns the value described by @var{result} from
>>>>> the containing function. You should specify, for @var{result}, a value
>>>>> returned by @code{__builtin_apply}.
>>>>> @enddefbuiltin
>>>>>
>>>>> I don't see __builtin_apply being used here?
>>>>
>>>> The prototype of the test case is from "__objc_block_forward" in
>>>> libobjc/sendmsg.c.
>>>>
>>>> void *args, *res;
>>>>
>>>> args = __builtin_apply_args ();
>>>> res = __objc_forward (rcv, op, args);
>>>> if (res)
>>>> __builtin_return (res);
>>>> else
>>>> ...
>>>>
>>>> The __builtin_apply_args puts the return values on stack by the alignment.
>>>> But the forward function can do anything and return a void* pointer.
>>>> IMHO the alignment might be broken. So I just simplified it to use a
>>>> void* pointer as the input argument of "__builtin_return" and skip
>>>> "__builtin_apply_args".
>>>
>>> But doesn't __objc_forward then break the contract between
>>> __builtin_apply_args and __builtin_return?
>>>
>>> That said, __builtin_return is a very special function, it's not supposed
>>> to deal with what you are fixing. At least I think so.
>>>
>>> IMHO the bug is in __objc_block_forward.
>>
>> If so, can we document that the memory objects pointed by input argument of
>> __builtin_return have to be aligned? Then we can force the alignment in
>> __builtin_return. The customer function can do anything if gcc doesn't state
>> that.
>
> I don't think they have to be aligned - they have to adhere to the ABI
> which __builtin_apply_args ensures. But others might know more details
> here.
>
>> Thanks
>> Gui Haochen
>>
>>>
>>> Richard.
>>>
>>>>
>>>> Thanks
>>>> Gui Haochen
next prev parent reply other threads:[~2023-11-13 8:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-09 5:41 HAO CHEN GUI
2023-11-09 11:41 ` Richard Biener
2023-11-10 7:52 ` HAO CHEN GUI
2023-11-10 9:06 ` Richard Biener
2023-11-10 10:09 ` HAO CHEN GUI
2023-11-10 13:39 ` Richard Biener
[not found] ` <e8bfd189-5c8b-4a1b-bc84-d3fe0cb1a032@linux.ibm.com>
2023-11-13 8:09 ` HAO CHEN GUI [this message]
2023-11-13 9:38 ` Fwd: " Richard Biener
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=5cd48c76-a783-4577-8035-0ab922e32855@linux.ibm.com \
--to=guihaoc@linux.ibm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=linkw@linux.ibm.com \
--cc=pinskia@gmail.com \
--cc=richard.guenther@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).