From 5ed8b2172afbe61bd9ad1737567a40f5ab0175eb Mon Sep 17 00:00:00 2001 From: Tulio Magno Quites Machado Filho Date: Mon, 31 Jul 2023 17:19:01 -0300 Subject: [PATCH] Fix rhbz #2228944 --- .llvm.metadata | 6 ++++++ D156379.diff | 46 ++++++++++++++++++++++++++++++++++++++++++++++ llvm.spec | 8 +++++++- 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 .llvm.metadata create mode 100644 D156379.diff diff --git a/.llvm.metadata b/.llvm.metadata new file mode 100644 index 0000000..bb40cbf --- /dev/null +++ b/.llvm.metadata @@ -0,0 +1,6 @@ +072d2fb4b10f95d06189de00eb7f7e9b35c54e9a llvm-16.0.6.src.tar.xz +bfc74b3868c69ce674a583c91e938b6d4cf0fded llvm-16.0.6.src.tar.xz.sig +0de534cfef38697e115c3ae80634765f05e78e5b cmake-16.0.6.src.tar.xz +2db5c88fe9277bb0fa85f49b58e946e49ff235c2 cmake-16.0.6.src.tar.xz.sig +5b1a58de6ed9d154a38edb6386a5749576e0b96a third-party-16.0.6.src.tar.xz +51ad6a8ccc5ccd40faff6f1c98a2f33a9b600f88 third-party-16.0.6.src.tar.xz.sig diff --git a/D156379.diff b/D156379.diff new file mode 100644 index 0000000..6d7aef1 --- /dev/null +++ b/D156379.diff @@ -0,0 +1,46 @@ +diff --git a/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp b/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp +--- a/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp ++++ b/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp +@@ -1152,6 +1152,11 @@ + } + } + ++ // Type legalization (via getNumberOfParts) can't handle structs ++ if (TLI->getValueType(DL, Src, true) == MVT::Other) ++ return BaseT::getMemoryOpCost(Opcode, Src, Alignment, AddressSpace, ++ CostKind); ++ + unsigned NumOps = + (Src->isVectorTy() ? getNumVectorRegs(Src) : getNumberOfParts(Src)); + +diff --git a/llvm/test/Analysis/CostModel/SystemZ/struct-cost-crash.ll b/llvm/test/Analysis/CostModel/SystemZ/struct-cost-crash.ll +new file mode 100644 +--- /dev/null ++++ b/llvm/test/Analysis/CostModel/SystemZ/struct-cost-crash.ll +@@ -0,0 +1,25 @@ ++; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 2 ++; RUN: opt -passes="print" 2>&1 -disable-output < %s | FileCheck %s ++; ++; Check that SystemZTTIImpl::getMemoryOpCost doesn't try to legalize structs, ++; which was failing llvm_unreachable in MVT::getVT. ++ ++target datalayout = "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64" ++target triple = "s390x-unknown-linux-gnu" ++ ++declare { i64, i32 } @bar() ++ ++define i8 @foo() { ++; CHECK-LABEL: 'foo' ++; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: br label %1 ++; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %2 = call { i64, i32 } @bar() ++; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: store { i64, i32 } %2, ptr inttoptr (i64 16 to ptr), align 16 ++; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: br label %1 ++; ++ br label %1 ++ ++1: ; preds = %1, %0 ++ %2 = call { i64, i32 } @bar() ++ store { i64, i32 } %2, ptr inttoptr (i64 16 to ptr), align 16 ++ br label %1 ++} + diff --git a/llvm.spec b/llvm.spec index e6f6765..3ba9b53 100644 --- a/llvm.spec +++ b/llvm.spec @@ -101,7 +101,7 @@ Name: %{pkg_name} Version: %{maj_ver}.%{min_ver}.%{patch_ver}%{?rc_ver:~rc%{rc_ver}} -Release: 2%{?dist} +Release: 3%{?dist} Summary: The Low Level Virtual Machine License: Apache-2.0 WITH LLVM-exception OR NCSA @@ -125,6 +125,9 @@ Patch101: 0001-Deactivate-markdown-doc.patch Patch1: 0001-SystemZ-Improve-error-messages-for-unsupported-reloc.patch # See https://reviews.llvm.org/D137890 for the next two patches Patch2: 0001-llvm-Add-install-targets-for-gtest.patch +# Backport of https://reviews.llvm.org/D156379 from LLVM 18. +Patch3: D156379.diff + # Patching third-party dir with a 200 offset in patch number Patch201: 0201-third-party-Add-install-targets-for-gtest.patch @@ -646,6 +649,9 @@ fi %endif %changelog +* Thu Aug 03 2023 Tulio Magno Quites Machado Filho - 16.0.6-3 +- Fix rhbz #2228944 + * Wed Jul 19 2023 Tulio Magno Quites Machado Filho - 16.0.6-2 - Improve error messages for unsupported relocs on s390x (rhbz#2216906) - Disable LLVM_UNREACHABLE_OPTIMIZE