public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Georgy Yakovlev" <gyakovlev@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lang/rust/, dev-lang/rust/files/
Date: Wed, 25 May 2022 21:09:48 +0000 (UTC)	[thread overview]
Message-ID: <1653512972.3b7815004b8f2952c642c81bbfb37cd7945e6cc3.gyakovlev@gentoo> (raw)

commit:     3b7815004b8f2952c642c81bbfb37cd7945e6cc3
Author:     Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
AuthorDate: Wed May 25 20:08:49 2022 +0000
Commit:     Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
CommitDate: Wed May 25 21:09:32 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3b781500

dev-lang/rust: add llvm patches to 1.61.0 to fix SIGFPE

Bug: https://bugs.gentoo.org/847421
Signed-off-by: Georgy Yakovlev <gyakovlev <AT> gentoo.org>

 .../rust/files/1.61.0-llvm_addrspacecast.patch     | 52 +++++++++++++++++
 .../files/1.61.0-llvm_selectInterleaveCount.patch  | 66 ++++++++++++++++++++++
 .../{rust-1.61.0.ebuild => rust-1.61.0-r1.ebuild}  |  2 +
 3 files changed, 120 insertions(+)

diff --git a/dev-lang/rust/files/1.61.0-llvm_addrspacecast.patch b/dev-lang/rust/files/1.61.0-llvm_addrspacecast.patch
new file mode 100644
index 000000000000..9f2ca6ff667b
--- /dev/null
+++ b/dev-lang/rust/files/1.61.0-llvm_addrspacecast.patch
@@ -0,0 +1,52 @@
+From 67a290460c374d5e0d18a06c798896cac0b19e59 Mon Sep 17 00:00:00 2001
+From: Fraser Cormack <fraser@codeplay.com>
+Date: Wed, 16 Mar 2022 10:14:07 +0000
+Subject: [PATCH] [VectorCombine] Insert addrspacecast when crossing address
+ space boundaries
+
+We can not bitcast pointers across different address spaces. This was
+previously fixed in D89577 but then in D93229 an enhancement was added
+which peeks further through the ponter operand, opening up the
+possibility that address-space violations could be introduced.
+
+Instead of bailing as the previous fix did, simply insert an
+addrspacecast cast instruction.
+
+Reviewed By: lebedev.ri
+
+Differential Revision: https://reviews.llvm.org/D121787
+
+(cherry picked from commit 2e44b7872bc638ed884ae4aa86e38b3b47e0b65a)
+---
+ llvm/lib/Transforms/Vectorize/VectorCombine.cpp |  8 ++------
+ .../AMDGPU/as-transition-inseltpoison.ll        |  4 +---
+ .../VectorCombine/AMDGPU/as-transition.ll       |  4 +---
+ .../VectorCombine/X86/load-inseltpoison.ll      | 17 +++++++++++++++++
+ 4 files changed, 21 insertions(+), 12 deletions(-)
+
+diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+index 620d388199e0..258f6c67e54d 100644
+--- a/src/llvm-project/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
++++ b/src/llvm-project/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+@@ -152,12 +152,7 @@ bool VectorCombine::vectorizeLoadInsert(Instruction &I) {
+   Value *SrcPtr = Load->getPointerOperand()->stripPointerCasts();
+   assert(isa<PointerType>(SrcPtr->getType()) && "Expected a pointer type");
+ 
+-  // If original AS != Load's AS, we can't bitcast the original pointer and have
+-  // to use Load's operand instead. Ideally we would want to strip pointer casts
+-  // without changing AS, but there's no API to do that ATM.
+   unsigned AS = Load->getPointerAddressSpace();
+-  if (AS != SrcPtr->getType()->getPointerAddressSpace())
+-    SrcPtr = Load->getPointerOperand();
+ 
+   // We are potentially transforming byte-sized (8-bit) memory accesses, so make
+   // sure we have all of our type-based constraints in place for this target.
+@@ -245,7 +240,8 @@ bool VectorCombine::vectorizeLoadInsert(Instruction &I) {
+   // It is safe and potentially profitable to load a vector directly:
+   // inselt undef, load Scalar, 0 --> load VecPtr
+   IRBuilder<> Builder(Load);
+-  Value *CastedPtr = Builder.CreateBitCast(SrcPtr, MinVecTy->getPointerTo(AS));
++  Value *CastedPtr = Builder.CreatePointerBitCastOrAddrSpaceCast(
++      SrcPtr, MinVecTy->getPointerTo(AS));
+   Value *VecLd = Builder.CreateAlignedLoad(MinVecTy, CastedPtr, Alignment);
+   VecLd = Builder.CreateShuffleVector(VecLd, Mask);

diff --git a/dev-lang/rust/files/1.61.0-llvm_selectInterleaveCount.patch b/dev-lang/rust/files/1.61.0-llvm_selectInterleaveCount.patch
new file mode 100644
index 000000000000..71a4e8df75d8
--- /dev/null
+++ b/dev-lang/rust/files/1.61.0-llvm_selectInterleaveCount.patch
@@ -0,0 +1,66 @@
+From fe8a27acd716a42667f5a572f52f2b04636010ff Mon Sep 17 00:00:00 2001
+From: Florian Hahn <flo@fhahn.com>
+Date: Tue, 29 Mar 2022 22:52:42 +0100
+Subject: [PATCH] [LV] Handle zero cost loops in selectInterleaveCount.
+
+In some case, like in the added test case, we can reach
+selectInterleaveCount with loops that actually have a cost of 0.
+
+Unfortunately a loop cost of 0 is also used to communicate that the cost
+has not been computed yet. To resolve the crash, bail out if the cost
+remains zero after computing it.
+
+This seems like the best option, as there are multiple code paths that
+return a cost of 0 to force a computation in selectInterleaveCount.
+Computing the cost at multiple places up front there would unnecessarily
+complicate the logic.
+
+Fixes #54413.
+
+(cherry picked from commit ecb4171dcbf1b433c9963fd605a74898303e850d)
+---
+ .../Transforms/Vectorize/LoopVectorize.cpp    | 22 ++++----
+ ...ct-interleave-count-loop-with-cost-zero.ll | 50 +++++++++++++++++++
+ 2 files changed, 62 insertions(+), 10 deletions(-)
+ create mode 100644 llvm/test/Transforms/LoopVectorize/X86/pr54413-select-interleave-count-loop-with-cost-zero.ll
+
+diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+index 21c16f07e237..e1cc7946073e 100644
+--- a/src/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
++++ b/src/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+@@ -6035,6 +6035,18 @@ unsigned LoopVectorizationCostModel::selectInterleaveCount(ElementCount VF,
+       !(InterleaveSmallLoopScalarReduction && HasReductions && VF.isScalar()))
+     return 1;
+ 
++  // If we did not calculate the cost for VF (because the user selected the VF)
++  // then we calculate the cost of VF here.
++  if (LoopCost == 0) {
++    InstructionCost C = expectedCost(VF).first;
++    assert(C.isValid() && "Expected to have chosen a VF with valid cost");
++    LoopCost = *C.getValue();
++
++    // Loop body is free and there is no need for interleaving.
++    if (LoopCost == 0)
++      return 1;
++  }
++
+   RegisterUsage R = calculateRegisterUsage({VF})[0];
+   // We divide by these constants so assume that we have at least one
+   // instruction that uses at least one register.
+@@ -6126,16 +6138,6 @@ unsigned LoopVectorizationCostModel::selectInterleaveCount(ElementCount VF,
+ 
+   assert(IC > 0 && "Interleave count must be greater than 0.");
+ 
+-  // If we did not calculate the cost for VF (because the user selected the VF)
+-  // then we calculate the cost of VF here.
+-  if (LoopCost == 0) {
+-    InstructionCost C = expectedCost(VF).first;
+-    assert(C.isValid() && "Expected to have chosen a VF with valid cost");
+-    LoopCost = *C.getValue();
+-  }
+-
+-  assert(LoopCost && "Non-zero loop cost expected");
+-
+   // Interleave if we vectorized this loop and there is a reduction that could
+   // benefit from interleaving.
+   if (VF.isVector() && HasReductions) {

diff --git a/dev-lang/rust/rust-1.61.0.ebuild b/dev-lang/rust/rust-1.61.0-r1.ebuild
similarity index 99%
rename from dev-lang/rust/rust-1.61.0.ebuild
rename to dev-lang/rust/rust-1.61.0-r1.ebuild
index e503b90edf91..f8852b27e97e 100644
--- a/dev-lang/rust/rust-1.61.0.ebuild
+++ b/dev-lang/rust/rust-1.61.0-r1.ebuild
@@ -156,6 +156,8 @@ VERIFY_SIG_OPENPGP_KEY_PATH=${BROOT}/usr/share/openpgp-keys/rust.asc
 PATCHES=(
 	"${FILESDIR}"/1.55.0-ignore-broken-and-non-applicable-tests.patch
 	"${FILESDIR}"/1.61.0-gentoo-musl-target-specs.patch
+	"${FILESDIR}"/1.61.0-llvm_selectInterleaveCount.patch
+	"${FILESDIR}"/1.61.0-llvm_addrspacecast.patch
 )
 
 S="${WORKDIR}/${MY_P}-src"


             reply	other threads:[~2022-05-25 21:09 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-25 21:09 Georgy Yakovlev [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-05-17 15:08 [gentoo-commits] repo/gentoo:master commit in: dev-lang/rust/, dev-lang/rust/files/ Sam James
2025-04-23 11:37 Matt Jolly
2024-12-08  7:04 Sam James
2024-11-03  6:06 Matt Jolly
2024-07-04  1:15 Sam James
2024-05-31 21:03 Sam James
2024-03-09  2:56 WANG Xuerui
2024-02-10  7:49 Sam James
2024-02-10  4:49 Sam James
2024-01-31 13:56 Matt Turner
2023-07-20  9:49 WANG Xuerui
2023-06-20 19:51 Georgy Yakovlev
2023-06-02  3:06 Georgy Yakovlev
2023-03-21  0:10 Georgy Yakovlev
2023-02-08 22:36 Georgy Yakovlev
2023-01-28 19:34 Georgy Yakovlev
2022-12-20  7:12 Georgy Yakovlev
2022-11-05  5:57 Georgy Yakovlev
2022-09-25  6:37 Georgy Yakovlev
2022-09-13 22:59 Georgy Yakovlev
2022-05-26 16:36 Georgy Yakovlev
2022-05-24 19:44 Georgy Yakovlev
2022-01-29 17:07 Georgy Yakovlev
2021-12-26  8:58 Georgy Yakovlev
2021-09-13 15:07 Georgy Yakovlev
2021-07-03  7:03 Georgy Yakovlev
2021-06-18  5:26 Georgy Yakovlev
2021-05-05 20:16 Georgy Yakovlev
2021-04-27 11:55 Georgy Yakovlev
2021-04-18 10:30 Georgy Yakovlev
2021-02-05 19:31 Georgy Yakovlev
2021-02-02 23:52 Georgy Yakovlev
2020-10-12  5:14 Georgy Yakovlev
2020-10-09  6:24 Georgy Yakovlev
2020-07-31  9:34 Georgy Yakovlev
2020-04-25  6:13 Georgy Yakovlev
2020-03-30 22:23 Georgy Yakovlev
2020-02-05  9:01 Georgy Yakovlev
2019-12-30  9:59 Georgy Yakovlev
2019-12-20  0:53 Georgy Yakovlev
2019-12-20  0:53 Georgy Yakovlev
2019-10-02 18:42 Georgy Yakovlev
2019-08-16  5:45 Georgy Yakovlev
2019-07-09 16:49 Georgy Yakovlev
2019-07-08 23:01 Georgy Yakovlev
2019-04-12  5:08 Georgy Yakovlev
2019-02-19  1:24 Thomas Deutschmann
2019-02-01  4:36 Georgy Yakovlev
2019-01-26  3:50 Georgy Yakovlev
2019-01-19 20:28 Thomas Deutschmann
2018-11-14 16:16 Dirkjan Ochtman
2018-05-14 14:41 Dirkjan Ochtman
2018-01-27 13:24 Dirkjan Ochtman
2016-11-08 18:44 Doug Goldstein

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1653512972.3b7815004b8f2952c642c81bbfb37cd7945e6cc3.gyakovlev@gentoo \
    --to=gyakovlev@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox