From 1968652869d779ac8aa25eac4ef5b50b4ec68644 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 #2224885 --- D156379.diff | 46 ++++++++++++++++++++++++++++++++++++++++++++++ llvm.spec | 8 +++++++- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 D156379.diff 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 912790d..21c1079 100644 --- a/llvm.spec +++ b/llvm.spec @@ -75,7 +75,7 @@ Name: %{pkg_name} Version: %{maj_ver}.%{min_ver}.%{patch_ver}%{?rc_ver:~rc%{rc_ver}} -Release: 1%{?dist} +Release: 2%{?dist} Summary: The Low Level Virtual Machine License: Apache-2.0 WITH LLVM-exception OR NCSA @@ -90,6 +90,9 @@ Source6: release-keys.asc # 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 + # RHEL-specific patch to avoid unwanted recommonmark dep Patch101: 0101-Deactivate-markdown-doc.patch # Patching third-party dir with a 200 offset in patch number @@ -563,6 +566,9 @@ fi %endif %changelog +* Thu Aug 03 2023 Tulio Magno Quites Machado Filho - 16.0.6-2 +- Fix rhbz #2224885 + * Tue Jul 11 2023 Tulio Magno Quites Machado Filho - 16.0.6-1 - Update to LLVM 16.0.6