diff options
author | Craig Topper <craig.topper@sifive.com> | 2024-09-18 18:29:32 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-18 18:29:32 -0700 |
commit | e494e2a29449a5ce7fce16b5dc1d0033b1ba69e8 (patch) | |
tree | 9725e56c2e30885f2088c36c25710458765a9106 /llvm/lib/CodeGen/MachineVerifier.cpp | |
parent | d21a43579e36af4aa90bf541aa8bab33e7500297 (diff) | |
download | llvm-e494e2a29449a5ce7fce16b5dc1d0033b1ba69e8.zip llvm-e494e2a29449a5ce7fce16b5dc1d0033b1ba69e8.tar.gz llvm-e494e2a29449a5ce7fce16b5dc1d0033b1ba69e8.tar.bz2 |
[MachineVerifier] Improve G_EXTRACT_SUBVECTOR checking (#109202)
Check that the destination of G_EXTRACT_SUBVECTOR is smaller than the
source. Improve wording of error messages.
Diffstat (limited to 'llvm/lib/CodeGen/MachineVerifier.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineVerifier.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp index 1fcbeee..651de06 100644 --- a/llvm/lib/CodeGen/MachineVerifier.cpp +++ b/llvm/lib/CodeGen/MachineVerifier.cpp @@ -1769,7 +1769,7 @@ void MachineVerifier::verifyPreISelGenericInstruction(const MachineInstr *MI) { } if (!SrcTy.isVector()) { - report("First source must be a vector", MI); + report("Source must be a vector", MI); break; } @@ -1783,6 +1783,12 @@ void MachineVerifier::verifyPreISelGenericInstruction(const MachineInstr *MI) { break; } + if (ElementCount::isKnownGT(DstTy.getElementCount(), + SrcTy.getElementCount())) { + report("Destination vector must be smaller than source vector", MI); + break; + } + uint64_t Idx = IndexOp.getImm(); uint64_t DstMinLen = DstTy.getElementCount().getKnownMinValue(); if (Idx % DstMinLen != 0) { @@ -1793,10 +1799,9 @@ void MachineVerifier::verifyPreISelGenericInstruction(const MachineInstr *MI) { } uint64_t SrcMinLen = SrcTy.getElementCount().getKnownMinValue(); - if (SrcTy.isScalable() == DstTy.isScalable() && - (Idx >= SrcMinLen || Idx + DstMinLen > SrcMinLen)) { - report("Source type and index must not cause extract to overrun to the " - "destination type", + if (Idx >= SrcMinLen || Idx + DstMinLen > SrcMinLen) { + report("Destination type and index must not cause extract to overrun the " + "source vector", MI); break; } |