Resolves: rhbz#2228944
This commit is contained in:
Tulio Magno Quites Machado Filho 2023-07-31 17:19:01 -03:00
parent a7e5ce65f5
commit 72eb025706
2 changed files with 53 additions and 1 deletions

46
D156379.diff Normal file
View File

@ -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<cost-model>" 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
+}

View File

@ -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 <tuliom@redhat.com> - 16.0.6-3
- Fix rhbz #2228944
* Wed Jul 19 2023 Tulio Magno Quites Machado Filho <tuliom@redhat.com> - 16.0.6-2
- Improve error messages for unsupported relocs on s390x (rhbz#2216906)
- Disable LLVM_UNREACHABLE_OPTIMIZE