aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineVerifier.cpp
diff options
context:
space:
mode:
authorRoman Tereshin <rtereshin@apple.com>2018-05-07 22:31:47 +0000
committerRoman Tereshin <rtereshin@apple.com>2018-05-07 22:31:47 +0000
commitd29fc892226e9a4fbab8580533e5589b50fb0080 (patch)
tree3edbe6cc65fae3ab343ba680663f0013042d03bb /llvm/lib/CodeGen/MachineVerifier.cpp
parentf487edae49368e1fb620a3597c61deef4275aa86 (diff)
downloadllvm-d29fc892226e9a4fbab8580533e5589b50fb0080.zip
llvm-d29fc892226e9a4fbab8580533e5589b50fb0080.tar.gz
llvm-d29fc892226e9a4fbab8580533e5589b50fb0080.tar.bz2
[MachineVerifier][GlobalISel] Checking that generic instrs have LLTs on all vregs
Every generic machine instruction must have generic virtual registers only, that is, have a low-level type attached to each operand. Previously MachineVerifier would catch a type missing on an operand only if the previous operand for the the same type index exists and have a type attached to it and it will report it as a type mismatch. This is incosistent behaviour and a misleading error message. This commit makes sure MachineVerifier explicitly checks that the types are there for every operand and if not provides a straightforward error message. Reviewers: qcolombet t.p.northover bogner ab Reviewed By: qcolombet Subscribers: rovka, kristof.beyls, llvm-commits Differential Revision: https://reviews.llvm.org/D46455 llvm-svn: 331694
Diffstat (limited to 'llvm/lib/CodeGen/MachineVerifier.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineVerifier.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp
index f2cdcaa..ab5b389 100644
--- a/llvm/lib/CodeGen/MachineVerifier.cpp
+++ b/llvm/lib/CodeGen/MachineVerifier.cpp
@@ -930,16 +930,26 @@ void MachineVerifier::visitMachineInstrBefore(const MachineInstr *MI) {
const MachineOperand *MO = &MI->getOperand(I);
LLT OpTy = MRI->getType(MO->getReg());
- if (Types[TypeIdx].isValid() && Types[TypeIdx] != OpTy)
- report("type mismatch in generic instruction", MI);
- Types[TypeIdx] = OpTy;
+ // Don't report a type mismatch if there is no actual mismatch, only a
+ // type missing, to reduce noise:
+ if (OpTy.isValid()) {
+ // Only the first valid type for a type index will be printed: don't
+ // overwrite it later so it's always clear which type was expected:
+ if (!Types[TypeIdx].isValid())
+ Types[TypeIdx] = OpTy;
+ else if (Types[TypeIdx] != OpTy)
+ report("Type mismatch in generic instruction", MO, I, OpTy);
+ } else {
+ // Generic instructions must have types attached to their operands.
+ report("Generic instruction is missing a virtual register type", MO, I);
+ }
}
// Generic opcodes must not have physical register operands.
for (unsigned I = 0; I < MI->getNumOperands(); ++I) {
const MachineOperand *MO = &MI->getOperand(I);
if (MO->isReg() && TargetRegisterInfo::isPhysicalRegister(MO->getReg()))
- report("Generic instruction cannot have physical register", MI);
+ report("Generic instruction cannot have physical register", MO, I);
}
}