GlobalISel: Fix verifier crashing on non-register operands

Also correct the wording of error on subregisters.

llvm-svn: 353128
This commit is contained in:
Matt Arsenault 2019-02-05 00:53:22 +00:00
parent d99af23765
commit 2bf74ec8c5
2 changed files with 16 additions and 2 deletions

View File

@ -933,6 +933,11 @@ void MachineVerifier::verifyPreISelGenericInstruction(const MachineInstr *MI) {
Types.resize(std::max(TypeIdx + 1, Types.size()));
const MachineOperand *MO = &MI->getOperand(I);
if (!MO->isReg()) {
report("generic instruction must use register operands", MI);
continue;
}
LLT OpTy = MRI->getType(MO->getReg());
// Don't report a type mismatch if there is no actual mismatch, only a
// type missing, to reduce noise:
@ -1517,7 +1522,7 @@ MachineVerifier::visitMachineOperand(const MachineOperand *MO, unsigned MONum) {
return;
}
if (SubIdx) {
report("Generic virtual register does not subregister index", MO,
report("Generic virtual register does not allow subregister index", MO,
MONum);
return;
}

View File

@ -1,4 +1,4 @@
#RUN: not llc -o - -global-isel -run-pass=none -verify-machineinstrs %s 2>&1 | FileCheck %s
#RUN: not llc -march=aarch64 -o - -global-isel -run-pass=none -verify-machineinstrs %s 2>&1 | FileCheck %s
# REQUIRES: global-isel, aarch64-registered-target
---
@ -25,4 +25,13 @@ body: |
; CHECK: Bad machine code: Explicit definition marked as use
G_ADD %0, %1
; CHECK: Bad machine code: generic instruction must use register operands
%5:_(s32) = G_ADD %0, 1
%6:_(s64) = G_CONSTANT i64 0
; CHECK: Bad machine code: Type mismatch in generic instruction
; CHECK: Bad machine code: Generic virtual register does not allow subregister index
%8:_(s32) = G_ADD %6.sub_32:_(s64), %0
...