From nobody Tue Nov 10 10:49:10 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 4jP3LG3zzxz6yC17 for ; Tue, 10 Nov 2026 10:49:10 +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 4jP3LG29f2z4Zl8 for ; Tue, 10 Nov 2026 10:49:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794307750; 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=p+NKVrRjFlBQ5lKUpzqRVRZGuwKl67wnm5sCMG77Td0=; b=k2S/tjkPXuTndI1wXoGWa4SlDle61BROGArTS6lTDYASKpEJKSov1qkLyc6nESaF9yRwVM 7RP30ujb2DhW+ek3RevXWIopu31AkOSKsg3wKjOQzOJNy21QvFALjohW4poMq3Mj+n9GTA g/N2zGd6fWbIglGFF64aMvRhOyQe0tmjdRe3J5gZ80JkUd7OcR7sTbSX4+1ZzV51OTviEF gEoltDcTZ2LjKjNJVZ9Nj+OdcOq3j8hk3pWiXWMa6H+eJO86Y/3g28rRr+YAptO/h6QXJS O4jAmlHRYOCDRZ6qrLnDHXUBtF29KrcBLMpQ85kRBHibrpCLx3D2lqTx5Lqq9w== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794307750; b=p0DU5nKg+vPfvUgf4ij2PEkN436Uk/JJKxv701ql+xE8EPViUZqAB2O49/nxHUxtYWGmqC y0a8at24cNxCglljkaaVYSHAFD2PoxYuYDN9z5oLA91TFmyJH+HpMW73zNUEhbDIvzTGFl A7fCw72sr/WflHSq1l5HC89qvwF3WAd99tnfFZQZtDF7mXx8gynK+iinDlw707jvpYZw5c 5NA9T22nLT3WQzuOyWBcbeeTKi7jBj32b6gEZiFU2pVIDhStJuMDvYRmGsnlMGv2UzrKiG UsjKrk/x4n3lSLBYJYKCI/rdwvUmT/SKLIBwU1JB90hBtkox/0JHIiRprHicBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794307750; 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=p+NKVrRjFlBQ5lKUpzqRVRZGuwKl67wnm5sCMG77Td0=; b=ax87m9nHXmbhuujOfUuh0IWo2vaYjRVkgXZA/ww9IIu2bjSdqji/Itt6QQW1ugU4u0sqsD yZp1r1Le/YNhS6xdp+ysd6tF3lL+QAxbeBjLf7mxsNBp6c2/KwwRErY801gvRIksxeNcFL gUWdf5XyhzQu1CbJ5NSEGJ/qayif/3JzayLzv9+VCAzlkMyc6gp0N5dtW/NVBqZtCiNWLj 7u4FQbpd79UBtRExEG4EBFyCkU3oiAWGmz4wrou1tl3zBBfqOMVugGChnwNmr+jw/ChFwR OHjAhmdMoOGvkZNKLnU65Nqvwbr5PEAalLs7KwOeKSYZCwATHQ2cbSRvRSMHbg== 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 4jP3LG1BkJzNZG for ; Tue, 10 Nov 2026 10:49:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 9dd8 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 10 Nov 2026 10:49:10 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Piotr Kubaj Subject: git: e56090afb68b - main - 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/main X-Git-Reftype: branch X-Git-Commit: e56090afb68b6c036d6b54c7b66d762d98bd96d0 Auto-Submitted: auto-generated Date: Tue, 10 Nov 2026 10:49:10 +0000 Message-Id: <6af2f6a6.9dd8.3757b9cc@gitrepo.freebsd.org> The branch main has been updated by pkubaj: URL: https://cgit.FreeBSD.org/src/commit/?id=e56090afb68b6c036d6b54c7b66d762d98bd96d0 commit e56090afb68b6c036d6b54c7b66d762d98bd96d0 Author: Piotr Kubaj AuthorDate: 2026-11-09 18:58:07 +0000 Commit: Piotr Kubaj CommitDate: 2026-11-10 10:49:06 +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 --- .../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) ||