[llvm] [GlobalISel] Catching inconsistencies in load memory, result, and range metadata type (PR #121247)

Renat Idrisov via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 6 09:55:40 PST 2025


================
@@ -1274,6 +1274,24 @@ 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()) {
+          auto operandBits = [](const MDOperand &o) -> unsigned {
+            ConstantInt *i = mdconst::dyn_extract<ConstantInt>(o);
+            if (!i->isNegative())
+              return i->getValue().getActiveBits();
+            APInt reversed(i->getValue());
----------------
parsifal-47 wrote:

This is something I still do not understand:

> The verifier should reject cases like this:
> ...
> !0 = !{i64 -4294967295, i64 4294967296}
> ...
> %3:_(<2 x s32>) = G_LOAD %0(p1) :: (volatile load (s64), align 4, !range !0, addrspace 1)

but if we get the information about the type, it is "i64" and there is a match between 2*32 == 64, no issues, you mentioned vector or scalar is not important, what would be the reason to reject this instruction?

https://github.com/llvm/llvm-project/pull/121247


More information about the llvm-commits mailing list