From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by sourceware.org (Postfix) with ESMTPS id 280503858D32 for ; Fri, 10 Nov 2023 13:39:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 280503858D32 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 280503858D32 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::230 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699623557; cv=none; b=S8JVxnH3An9oU7Flv/fS0RWcp8Yy6gCSQ7UlKbmGap94MJ77esHBklUCdg1BFVtXEIDCgokJoCeGpCzQzFG2Gc1sd6WDhVlXSjbQPkjFnknaFqGyyzBEXIpVmdfPBBk++nk9ow8xswMcRCWeT7BdEABeJHWuFivs8R1QzF1WQ9A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699623557; c=relaxed/simple; bh=0Xk2eSzWvzxitdXjTnwyUnUq/AyaD3RtNNTbYTg0Kfo=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=XPZnkFZZFmdooHAOJqyUdQ7zm4VS9lVHw5ci6S2D9Ewgzr3PJz2fB1cF/rc/m+eQD1huJT7qom09JnpJdfKorkmwDFi3fWbmCTEDsMb587hr82AGfCgXUwK4wdq9mB9tBO+N+EjB3+ONlp70M2FwFlPEzA7MP1EymL4d8qbqRDA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2c509d5ab43so28454521fa.0 for ; Fri, 10 Nov 2023 05:39:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699623554; x=1700228354; 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=tFffvBVkStbGbXgmMDGfNEkHMYIqviUPbGmQDR+txIs=; b=AljJBeMZBGnE6jd/QKmyUu3orswa+ZfARy9/1iAFcEoJs2hpuV4B/Ij4kWLcQBm8vo HOsje47fMcD2/eMr9L80U6vRTHlMstU07b6L+nq1nGGQXJD4l6ZHQt1xelHSd9raRG1k D8UF8zDrq3aPjzF9Z3R4GhyenvrGzig2RDbHrGaOIC5LPccFdHG/4dwbgpC+mdejJroO YawfEF83cGv5u5bYU6vcj3z5BlugJbVCqBvH6zqyBUcAV4U6wQd5PtFKn8VBfcC2Dado v5H1gNg9rsPQIciN1+g3+nWZDOp5V4pa1WOzKy/7YJLN3/1eIG4fUpo1hSt/qtPg0rS2 J96A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699623554; x=1700228354; 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=tFffvBVkStbGbXgmMDGfNEkHMYIqviUPbGmQDR+txIs=; b=a3077paAKdjldiulZZmY88RVaumWqUCo4NWgY9QxjLbLWti/7knbZzyqRc9BmeNj0I TM6k3RBc3AwuuFvi/zucJ9hbsfTF3N7wbNFiSZsOGdGKP6F1RLWixINGuE1iAm6z2Jp1 FKqvCPMMdycGX1WjJVHS1ofuOR8KrpcHcyJHRVaZ7c3QBFv+yJ0EPhGl/7XliZado2aL jvU/XoZQLlYWeKXGZvZtHJevVPvyPMGqJcciSPjFP2SXXYcKFMzyGzFnDk9Sh9ZZOVe+ 3N89W+vxKXrob0RSEKLvBUbb4dqB2AwTtRhzNc/y1E7raILjnM/GYeCx/8Og64Pbq7kG gIIA== X-Gm-Message-State: AOJu0YzBo99/sQC6/TmnM5a0aFI6XyOVpgfEXyyTYMQibdaqZ9IYNRoH DbG8AqP1rrEGnu8rMAGRRIVh0W/Hlw3m/vT27KM= X-Google-Smtp-Source: AGHT+IEfVjc59o8RhR8qGKZaEjt3KAhFUEfAM4Oc6YYLdRa9iFgVjbm5ufq3RiWny8o2UtcL5Sbe4CFw6vIfVWTgCd0= X-Received: by 2002:ac2:5304:0:b0:508:264e:2ded with SMTP id c4-20020ac25304000000b00508264e2dedmr3893990lfh.38.1699623554357; Fri, 10 Nov 2023 05:39:14 -0800 (PST) MIME-Version: 1.0 References: <620568e3-0eda-4793-815e-06b2f0620ad6@linux.ibm.com> In-Reply-To: <620568e3-0eda-4793-815e-06b2f0620ad6@linux.ibm.com> From: Richard Biener Date: Fri, 10 Nov 2023 14:39:02 +0100 Message-ID: Subject: Re: [PATCH, expand] Call misaligned memory reference in expand_builtin_return [PR112417] To: HAO CHEN GUI Cc: gcc-patches , "Kewen.Lin" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,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 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} fr= om > >>> the containing function. You should specify, for @var{result}, a val= ue > >>> 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 alignm= ent. > >> 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 suppos= ed > > 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 st= ate > 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