aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineVerifier.cpp
diff options
context:
space:
mode:
authorRenat Idrisov <4032256+parsifal-47@users.noreply.github.com>2025-01-28 05:54:34 -0800
committerGitHub <noreply@github.com>2025-01-28 20:54:34 +0700
commit11db7fb09b36e656a801117d6a2492133e9c2e46 (patch)
tree3024cc3f1b924c02e8d48928b9cdcd5465c1c0fd /llvm/lib/CodeGen/MachineVerifier.cpp
parent0cf6714279d4146ee5d6a5e34195d6fae56ed475 (diff)
downloadllvm-11db7fb09b36e656a801117d6a2492133e9c2e46.zip
llvm-11db7fb09b36e656a801117d6a2492133e9c2e46.tar.gz
llvm-11db7fb09b36e656a801117d6a2492133e9c2e46.tar.bz2
[GlobalISel] Catching inconsistencies in load memory, result, and range metadata type (#121247)
This is a fix for: https://github.com/llvm/llvm-project/issues/97290 Please let me know if that is the right way to address the issue. Thank you! --------- Co-authored-by: Renat Idrisov <parsifal-47@users.noreply.github.com> Co-authored-by: Matt Arsenault <arsenm2@gmail.com>
Diffstat (limited to 'llvm/lib/CodeGen/MachineVerifier.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineVerifier.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp
index 46ae3c6b..becf41b0a 100644
--- a/llvm/lib/CodeGen/MachineVerifier.cpp
+++ b/llvm/lib/CodeGen/MachineVerifier.cpp
@@ -1281,6 +1281,15 @@ void MachineVerifier::verifyPreISelGenericInstruction(const MachineInstr *MI) {
if (TypeSize::isKnownGT(MMO.getSize().getValue(),
ValTy.getSizeInBytes()))
report("load memory size cannot exceed result size", MI);
+
+ if (MMO.getRanges()) {
+ ConstantInt *i =
+ mdconst::extract<ConstantInt>(MMO.getRanges()->getOperand(0));
+ if (i->getIntegerType()->getBitWidth() !=
+ ValTy.getScalarType().getSizeInBits()) {
+ report("range is incompatible with the result type", MI);
+ }
+ }
} else if (MI->getOpcode() == TargetOpcode::G_STORE) {
if (TypeSize::isKnownLT(ValTy.getSizeInBytes(),
MMO.getSize().getValue()))