From nobody Sun Nov 15 19:37:52 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jSLr06nfWz710vg for ; Sun, 15 Nov 2026 19:37:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jSLr05Bg6z3CbB for ; Sun, 15 Nov 2026 19:37:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794771472; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6rGHKHf43lY+i0FW8dFLuwQ392jR9XNknuW+cVbq+YU=; b=ax6xhbvEFz9UUUOOVnbI3oT+Z/HJOBKQwIpyQEIt2q8L9VQr9L5YrJaz5QNoQ9IVTiTgE6 hsgOdUhxRJHEz0ACFr0+3QWgAYs/3XOoWjTVvaehwbMdfEjNLRPkDzhgWL6LMTgmNrsybg A2CKOE/smD9+rUukJtCUGtizoPpTEibmP6FT0y/X+H8SErTNeYym3lwxqT95KjfXUO529B Se3TF7bZ2H/7huH8mzucjrdKBCVMZhIUQ2IjccEhsyg9RU08ERxhXBDRhA6Ia4HElM31Ti LMC+Rmnus9eAR9yDrG0+0gAghFxDmx+imDx4L/vRqaQoDp9QxYni6XoDJS13Mw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794771472; b=Q6lSdmShzZVJdRUsE5x/QEBYFiLDf2IOHBWGSTckY5aWLQ1OoQ9Ze4jkFSzXcLjAbyh0VW f8IAGth25NNsiQnMN5inx0wrQiKz0Ys4chfwPX4lE3AXMHfzf2CtHYcIbUBUuHFs5xHrVi RB1YCKq+woC9bG9E86tA9wR/NAp4WGw6/9UV+PYM8J/+z+lkfTP3hxB0E/tPFu8t8iCmhA RcX94fQLHZSlnTBgkgum88OjlVlmDXTEswn9zmfxvRATrkq6i1zoPv/iNe/Ne5sB9Cyu63 3dI2SwgDCbnj7UOk0B+FUcOR1mqmfsD+5qrklMm8KthpKnaVe/q6TxAVYlcPZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794771472; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6rGHKHf43lY+i0FW8dFLuwQ392jR9XNknuW+cVbq+YU=; b=SUStT6QFOoUSlRkS1xJinSEdtGeBTva9csng5YHiL+8pk7W/zld29051TnCBllzAe+q85l DhI/h7MMluGofysNBUmw44qAsKXKvyAg+loFWKPwxHOvnWOLtHKMVPxhsxzbhphQgG2FSf E47lmel6h51YgIQs+z/TJrfomHXmOFAMDOCEVG592pNWIE7MA3k3X6AhaxU8oo/B7bk320 x3zAdXhW5TQTMisCoMPTijtfhzagZH7yEGXP29pndBghJ6F3+Td0jq50wFGER6ukBSmwcr +p8I8LcGwdhFLOaFfuztb0XRFEcz6TZ8s8882PPwlzvfYwXytP9RPXsuvnYwxw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jSLr047FkzL1Q for ; Sun, 15 Nov 2026 19:37:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 18fe1 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 15 Nov 2026 19:37:52 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Piotr Kubaj Subject: git: a778669c1d33 - stable/15 - Merge commit 72a20b8e2987 from llvm git (by Gabriel Baraldi): List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pkubaj X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: a778669c1d339b1f94c752003fc688d9a34e404a Auto-Submitted: auto-generated Date: Sun, 15 Nov 2026 19:37:52 +0000 Message-Id: <6afa0a10.18fe1.3790e2b3@gitrepo.freebsd.org> The branch stable/15 has been updated by pkubaj: URL: https://cgit.FreeBSD.org/src/commit/?id=a778669c1d339b1f94c752003fc688d9a34e404a commit a778669c1d339b1f94c752003fc688d9a34e404a Author: Piotr Kubaj AuthorDate: 2026-11-09 18:58:07 +0000 Commit: Piotr Kubaj CommitDate: 2026-11-15 19:37:44 +0000 Merge commit 72a20b8e2987 from llvm git (by Gabriel Baraldi): [SLPVectorizer] Check std::optional coming out of getPointersDiff (#175784) Fixes https://github.com/llvm/llvm-project/issues/175768 There are other unchecked uses std::optional in this pass but I couldn't figure out a test that triggers them This fixes a clang crash in the SLP vectorizer, hit when building audio/csound on powerpc64le. The hardened libc++ traps on the disengaged optional, so clang dies with exit code 133. The second hunk is adapted to llvm 21, where analyzeConstantStrideCandidate() is still isStridedLoad(). Reviewed by: dim MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D61354 (cherry picked from commit e56090afb68b6c036d6b54c7b66d762d98bd96d0) --- .../lib/Transforms/Vectorize/SLPVectorizer.cpp | 32 +++++++++++++++++----- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/contrib/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/contrib/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 2d50981690f4..90f9f44fc0ec 100644 --- a/contrib/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/contrib/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -6076,6 +6076,12 @@ static bool isStridedLoad(ArrayRef VL, ArrayRef PointerOps, Ptr0 = PointerOps[Order.front()]; PtrN = PointerOps[Order.back()]; } + // sortPtrAccesses only validates getPointersDiff for pairs relative to + // PointerOps[0], so compute every distance through PointerOps[0] (as in + // canVectorizeLoads); only differences are used below. + std::optional Diff0 = + getPointersDiff(ScalarTy, PointerOps[0], ScalarTy, Ptr0, DL, SE); + assert(Diff0 && "sortPtrAccesses should have validated this pointer"); // Iterate through all pointers and check if all distances are // unique multiple of Dist. SmallSet Dists; @@ -6083,8 +6089,12 @@ static bool isStridedLoad(ArrayRef VL, ArrayRef PointerOps, int64_t Dist = 0; if (Ptr == PtrN) Dist = Diff; - else if (Ptr != Ptr0) - Dist = *getPointersDiff(ScalarTy, Ptr0, ScalarTy, Ptr, DL, SE); + else if (Ptr != Ptr0) { + std::optional DistN = + getPointersDiff(ScalarTy, PointerOps[0], ScalarTy, Ptr, DL, SE); + assert(DistN && "sortPtrAccesses should have validated this pointer"); + Dist = *DistN - *Diff0; + } // If the strides are not the same or repeated, we can't // vectorize. if (((Dist / Stride) * Stride) != Dist || !Dists.insert(Dist).second) @@ -6162,10 +6172,18 @@ BoUpSLP::canVectorizeLoads(ArrayRef VL, const Value *VL0, Ptr0 = PointerOps[Order.front()]; PtrN = PointerOps[Order.back()]; } - std::optional Diff = - getPointersDiff(ScalarTy, Ptr0, ScalarTy, PtrN, *DL, *SE); + // sortPtrAccesses validates getPointersDiff for all pointers relative to + // PointerOps[0], so compute the span using PointerOps[0] as intermediate: + // Diff = offset(PtrN) - offset(Ptr0) relative to PointerOps[0] + std::optional Diff0 = + getPointersDiff(ScalarTy, PointerOps[0], ScalarTy, Ptr0, *DL, *SE); + std::optional DiffN = + getPointersDiff(ScalarTy, PointerOps[0], ScalarTy, PtrN, *DL, *SE); + assert(Diff0 && DiffN && + "sortPtrAccesses should have validated these pointers"); + int64_t Diff = *DiffN - *Diff0; // Check that the sorted loads are consecutive. - if (static_cast(*Diff) == Sz - 1) + if (static_cast(Diff) == Sz - 1) return LoadsState::Vectorize; if (isMaskedLoadCompress(VL, PointerOps, Order, *TTI, *DL, *SE, *AC, *DT, *TLI, [&](Value *V) { @@ -6174,7 +6192,7 @@ BoUpSLP::canVectorizeLoads(ArrayRef VL, const Value *VL0, })) return LoadsState::CompressVectorize; // Simple check if not a strided access - clear order. - bool IsPossibleStrided = *Diff % (Sz - 1) == 0; + bool IsPossibleStrided = Diff % (Sz - 1) == 0; // Try to generate strided load node. auto IsAnyPointerUsedOutGraph = IsPossibleStrided && any_of(PointerOps, [&](Value *V) { @@ -6184,7 +6202,7 @@ BoUpSLP::canVectorizeLoads(ArrayRef VL, const Value *VL0, }); if (IsPossibleStrided && isStridedLoad(VL, PointerOps, Order, *TTI, *DL, *SE, - IsAnyPointerUsedOutGraph, *Diff)) + IsAnyPointerUsedOutGraph, Diff)) return LoadsState::StridedVectorize; } if (!TTI->isLegalMaskedGather(VecTy, CommonAlignment) ||