Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w8Ur7-000ajP-36 for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Apr 2026 03:05:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w8Uq6-009UvQ-1O for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Apr 2026 03:04:54 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w8Uq6-009UvH-00 for pgsql-hackers@lists.postgresql.org; Fri, 03 Apr 2026 03:04:54 +0000 Received: from mail-dy1-x1330.google.com ([2607:f8b0:4864:20::1330]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w8Uq3-00000000HwJ-3xX3 for pgsql-hackers@lists.postgresql.org; Fri, 03 Apr 2026 03:04:53 +0000 Received: by mail-dy1-x1330.google.com with SMTP id 5a478bee46e88-2cc43ca447aso8861eec.1 for ; Thu, 02 Apr 2026 20:04:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775185491; cv=none; d=google.com; s=arc-20240605; b=QHsPEBAjoHwTg3huby5BrTr5pP+iFkCk9WNiKghSbyin/Bn3otyh48N70TI/onEGFm lPJBOe/uD8HqcYaJ2obaISxOPsblF8FMcWRjSh83+Uhcs+Us4HZLU2EmvZJKn4C+rYz9 Q+swLtFMtiamDUlns4eTXmdUktdPkyP1cTTX/Yz1Z4cvLGsPRVRcYUlZNL6+wWdLBWhl IirJWcr/sH6AU7CwI/u0dX455oQ5k/0NAIRKL4Ndwzx2/zyRxE2/zdVtSxD8KTVsVZd5 fEGM15FoTSkg1UirU7ELhhPFmOMzCBjA5aVs7gsDfGnIfBqGP67vuN0WzPvdshqAeEET Cykg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=JcM6MA+dx2+iYKSuY5prhMb0VaJzSzouDLXpdvKNbVk=; fh=HcLz5t12PiMK4oHCqzhKcspBnEoF3OEKNRaxOllpVTg=; b=ZJ3mojPIDK1kXJ1FWv2jZR7xqWoAk2OrR6cFXMs+YCY20SFINJkjV7i8xfiWkfBdvI jsgNNiFAqCH7GtNUiVsNELpjPcRFVgc84WsPpEOeJZt9UNO+/ZmmCdcrkmbMPGERMeDi 1xc6ImA8wSoquPFkYWAam+T+iJmBtE5nmHIcdJSu6/5Qk8aVyfHdd6cwUEAjK7jt/r05 oNVdAo7uUmCSmztSViSiOmt8WeTBB3Z1tE8yRhksUeSfFDo/Tw3juILeTZdAMY1NuRZr qL4/vA7ZYjY/cSMtgjJgqPH6F5uoKVXAgdZg6JbE+xBzR0lVAkLqBjuGygXDQnPPkla2 iNtg==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775185491; x=1775790291; darn=lists.postgresql.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=JcM6MA+dx2+iYKSuY5prhMb0VaJzSzouDLXpdvKNbVk=; b=o1vLGuWXGEDA6XtlC1mRP51mmyO0MCRAH3N9s5GqgjwVAgxbZfXkdZO12QgR8ELxVf Qky6Qfy+3phXdnDkP6+Yw4+8UA/X0ka8L2ZygU0PQk1CokSw62pHX7/WdmUhzzHDS3QL Qq0TSdgROUaKO5VNuQUeHmoN4Aq6XSs8c42bNvlxTx6yRvxevPllzfHAHIqWbO4Lcu+t x1sjpKzuuItu3YylnFvFSLC9U1vfs1Eg/1lBovkuCXqAqSEmsTqXUGrJv8tGmD8QcFV1 tUQAWiHEq4F/WTfzQx4ugvwcGlmFO+f5IN/ytz/x1KyivJh0p9Xq9oy2BgJbey8DfizL 6w5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775185491; x=1775790291; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=JcM6MA+dx2+iYKSuY5prhMb0VaJzSzouDLXpdvKNbVk=; b=W0XdUilRIzDD/MeX12zBkM6HbAqVTevquZUwT8xTuP3vAS80ZZpzLTvSS4l12UFgJW WJ0hTbb6CLmSgCYXR/ldeqU6CwY/JUDHuXsrXlMyfl8vWc23SokfTzDhElSCN71UD1xT Roy3KoxVSnO8uk0QqQ8rNWiuWr4xRYdZdiTRSzZJ/PSGSmDySlb4cLd737iaVOZrUc1k 4Z1pog9i1692RD1murRSgvgZOCyb6LORrnoCOyq/aqLoA9Z95cKSwFppuuzAyH0p6viP NN/MIalQU3Px42r1uoYkcAQpwRevLE/nMaTJJbxn7bU8Q02z9VeM2JBks9mHyTMNJzrF vj0w== X-Forwarded-Encrypted: i=1; AJvYcCV4KRrPtBGRnqPX+upqSalYEQ7V4uLCNd+vQA6e5SVQhH38ATWQ+rMq6qn5qv6NZOUbTCON2nmUdfzOpOJ/@lists.postgresql.org X-Gm-Message-State: AOJu0YzfkjCnMNk+7n7ebE8kS2KJHfLVh2SMsDr7wi5Mk3pefIFU2027 uSkWCMnqRXWVfeDsG2jjP83/EK9NykACmyHftTtZabaFW8U2RLZRB6h+vXcKg+pd6tmTzxfFvS8 lIIY2AIOAUblA/7kqESG7Zdlbi+rY19M= X-Gm-Gg: AeBDieu4zhiltwlrwZXKeYjp8T0eiSPStNFmEI6jzkncZgan/4IYR9jmxh/8CEi8ZoS UlJn10nJ/tqGHmNx6TBE7iv3Xue2b58D2pzP5ALjxiWE06malHm4YZZTPlQ7w4ZWnzLVaMQ7s6Z 2Ib4ODP4Hgd+ZK9Xh4ed4jkjC1SAq33MDiKQ5aeAnF7Wbv79FZwO2VbdkE6fQf2xqsayFGmLiO3 Z7hVV5qU7psqxjQLF1OhitIzTj+n+Ziok1JooGdNE/YcdF4AEPsVGKAqFbWg59+vNeaRcQnsBMk fDb01xk/aIIft9zlyu4buOHR6gon07EdSJcibkhMyIIZgHTPA7kOF6Fr3IDwE4SU X-Received: by 2002:a05:7300:cc12:b0:2be:681:91b2 with SMTP id 5a478bee46e88-2cbfd565513mr388015eec.6.1775185490782; Thu, 02 Apr 2026 20:04:50 -0700 (PDT) MIME-Version: 1.0 References: <2805479.1775001311@sss.pgh.pa.us> In-Reply-To: From: Thomas Munro Date: Fri, 3 Apr 2026 16:04:13 +1300 X-Gm-Features: AQROBzAzKGd9fGg6ugiqXJHh-sHIREQGtBSnWe1Xf4Wuu2fGeWz4YFoEBPtRySo Message-ID: Subject: Re: LLVM 22 To: Andres Freund Cc: Tom Lane , =?UTF-8?B?RGV2cmltIEfDvG5kw7x6?= , PostgreSQL Hackers , Matheus Alcantara , Anthonin Bonnefoy Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Apr 3, 2026 at 3:31=E2=80=AFAM Andres Freund w= rote: > > I see a few options, but I need to hack on them for a while to figure > > out the tradeoffs, or what I'm missing... after the freeze. > > I've experimented a bunch with this, it seems we need the larger changes = done > as part of the patchset for removing pointers from the expressions to act= ually > allow recent-ish LLVM to optimize this. I did verify that what we did di= dn't > have an effect with any other recent LLVM either. Yeah, I noticed this connection as well, coming at it from a keyhole how-do-I-fix-THIS-problem angle. It seemed to me that where ExecInitFunc() builds the code to compute argument values to push into &fcinfo->args[argno].value (a palloc'd FunctionCallInfoData object), it might first alloca the space and store the collid etc (and after return, it could lifetime.end it, or maybe the eventual ret in the caller is enough but I don't see any reason not to lifetime.end it ASAP), and then the destination would become a pointer into that, and the most natural thing would be a stack pointer-relative one, and then you'd have removed a major source of non-cacheability of compiled expressions. It took me a while to grok the function argument layout, which is ... this might be a stretch... a bit like Fortran, neither a linear stack nor a spaghetti stack, but just a bag of variables ready to be used as functions arguments, with recursion not permitted. And also to grok the quirks of our V1 calls that compelled you to do it like that. But I'm still learning the secrets of this code and I may be way off base in these musings, I haven't actually tried anything and it sounds like I should keep out of your way... > The real fix here might be to have a separate calling convention for the = very > common case of a scalar stable function with 1-3 arguments. We loose a f= air > bit of efficiency even in interpreted execution due to ferrying arguments= , > their nullness, and the nullness of the return value through memory. Yeah. I understand much better why you say that now. FunctionCallInfoData holds data with two different lifetimes, some of which might not be needed.