From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by sourceware.org (Postfix) with ESMTPS id 47B6A385DC1D for ; Mon, 13 Nov 2023 09:39:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 47B6A385DC1D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 47B6A385DC1D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::134 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699868354; cv=none; b=nyCbR4i6HBGjDDQDpPc9kCfLTEgtAIFa1vN6fHIN0ypB0BJAFwtC3w8JjJzypn1/KLsGYKr0RCEnLPWPDiL81eOWzu0OYhWt9keuNHRQXtK+guCzHOQlziC3+7jLJC3rgF11ki1agfABzPtK8sKybUskXGWMQjcU3N+dG2KOEBY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699868354; c=relaxed/simple; bh=tkdpKWaq8yqQ+9mZsDsDx1E+Yz/RpTTlO8IkB08InSw=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=MOfOyQ9wnax9eZwpqm1wbA4t90xDpKwpJxe8cPRgidjyB72zETAAvkvhd3IUFEMgxsQWGOmAxsLOsNAjoHzWDj6cqWa/IJqetjjmwSqKLjav0iUPAud+K1LibeWVphWb6sXnwcFhrjcZ1qqq4JHHzJNXo/3XErWzeQMOWGK0L6g= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-5079f9ec8d9so4656126e87.0 for ; Mon, 13 Nov 2023 01:39:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699868351; x=1700473151; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=q/fEwtWe1L1YWX8/W3gH0jLE7c45CoU4Z9c9HvSv8lI=; b=D6kcchU2DJv/H7ZrC1yZ/RjcMt6kclPZjzTQS1NuZlg8tXR/3eLGpGZpbE8FAPFOeJ lY9fKCyzP4WhFTWz3Pd1Sv39BInZMShYeCOB5axrzBkvUKg7RpYt+K70wiLmeTUuxC6N s5YbA7cH42kH8L79zi/d4lvLeC7hEP8X9eqtkK9FttI2k1JOj0MOVqi0C7zndrJnXhj2 FTdDVvdv7Lw3rNJXDX0vJm9TqYr+K7F4r4jQmXQRHs9k7mNrRzRE0ZAE3fDZKuV4JsYs mO/tyiZl9n208GGUXiueslTEBTRM0N5Jgv0DkDLneSTxAIHZ3tL+Z0shzVlniaFqjVJD n6yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699868351; x=1700473151; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q/fEwtWe1L1YWX8/W3gH0jLE7c45CoU4Z9c9HvSv8lI=; b=IG3bAdfgqO9A6vkAqs7p4mPVGZZbcynxvcTXi9VnhqrU+lmU5vLOgysXWIlJaYTMW9 L3/eXKzSf++HT1kl/V69yCx9IcVMlwboMXvaQTBJ16xz+yNbKOK0VH0Hb+MFWOh4pQ/3 6NkmSugfxcQYfBeKyVTzMzR1JnAguzcD8m7LYKPJzisnf0M56WgLcB+GQ0JW3ydYdjSJ DL/GmoTshGxwhUgQEMmu2FGjrgkAo+il/WP9O22jh6iUb6L/47yB3/yP1WhSe/PA4hEI LO/j3M+YsRymhW8tyErEs6EU5sUDUJ0D87/VYaFGi4d6Nhl0X4thtoist2sBToj3VAZo ySaQ== X-Gm-Message-State: AOJu0YyRdJOjQTY6o4/rjByHOzMGs7UGn7n14Ni6FCoNarNVqzJNdXt1 S29Gv3+wq+EWwmid1XK2oeuGXRYV2BLIRKFxkZQ= X-Google-Smtp-Source: AGHT+IFUoCMc+Fgf9fcbjBfw/T0CGNaGAmIx0WV9LQF87DGGF5Gp8KMqlo8os48b9ZEIQ8wcNQpDQU44ztn0MSi+CDM= X-Received: by 2002:a05:6512:2806:b0:501:b929:48af with SMTP id cf6-20020a056512280600b00501b92948afmr2786190lfb.34.1699868350430; Mon, 13 Nov 2023 01:39:10 -0800 (PST) MIME-Version: 1.0 References: <5cd48c76-a783-4577-8035-0ab922e32855@linux.ibm.com> In-Reply-To: <5cd48c76-a783-4577-8035-0ab922e32855@linux.ibm.com> From: Richard Biener Date: Mon, 13 Nov 2023 10:38:57 +0100 Message-ID: Subject: Re: Fwd: [PATCH, expand] Call misaligned memory reference in expand_builtin_return [PR112417] To: HAO CHEN GUI Cc: Andrew Pinski , "Kewen.Lin" , gcc-patches Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, Nov 13, 2023 at 9:09=E2=80=AFAM HAO CHEN GUI wrote: > > Sorry, forgot to cc gcc-patches. > > =E5=9C=A8 2023/11/13 16:05, HAO CHEN GUI =E5=86=99=E9=81=93: > > 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 =3D __builtin_apply_args (); > > res =3D __objc_forward (rcv, op, args); maybe this should use __builtin_apply and the __builtin_return use 'args', not 'res' as the return value? > > if (res) > > __builtin_return (res); > > else > > ... > > > > -------- =E8=BD=AC=E5=8F=91=E7=9A=84=E6=B6=88=E6=81=AF -------- > > =E4=B8=BB=E9=A2=98: Re: [PATCH, expand] Call misaligned memory referenc= e in expand_builtin_return [PR112417] > > =E6=97=A5=E6=9C=9F: Fri, 10 Nov 2023 14:39:02 +0100 > > From: Richard Biener > > =E6=94=B6=E4=BB=B6=E4=BA=BA: HAO CHEN GUI > > =E6=8A=84=E9=80=81: gcc-patches , Kewen.Lin > > > > On Fri, Nov 10, 2023 at 11:10=E2=80=AFAM HAO CHEN GUI wrote: > >> > >> Hi Richard, > >> > >> =E5=9C=A8 2023/11/10 17:06, Richard Biener =E5=86=99=E9=81=93: > >>> On Fri, Nov 10, 2023 at 8:52=E2=80=AFAM HAO CHEN GUI wrote: > >>>> > >>>> Hi Richard, > >>>> Thanks so much for your comments. > >>>> > >>>> =E5=9C=A8 2023/11/9 19:41, Richard Biener =E5=86=99=E9=81=93: > >>>>> 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 v= alue > >>>>> 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 =3D __builtin_apply_args (); > >>>> res =3D __objc_forward (rcv, op, args); > >>>> if (res) > >>>> __builtin_return (res); > >>>> else > >>>> ... > >>>> > >>>> The __builtin_apply_args puts the return values on stack by the alig= nment. > >>>> 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 supp= osed > >>> 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 argume= nt of > >> __builtin_return have to be aligned? Then we can force the alignment i= n > >> __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