[Mesa-dev] [PATCH] R600: Verify all instructions in the AsmPrinter on debug builds

Tom Stellard thomas.stellard at amd.com
Tue Feb 25 13:42:49 PST 2014


Make a call to R600's implementation of verifyInstruction() to
check that instructions are only using legal operands.
---
 lib/Target/R600/AMDGPUMCInstLower.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/Target/R600/AMDGPUMCInstLower.cpp b/lib/Target/R600/AMDGPUMCInstLower.cpp
index 4af535c..d6a7fb0 100644
--- a/lib/Target/R600/AMDGPUMCInstLower.cpp
+++ b/lib/Target/R600/AMDGPUMCInstLower.cpp
@@ -69,6 +69,14 @@ void AMDGPUMCInstLower::lower(const MachineInstr *MI, MCInst &OutMI) const {
 void AMDGPUAsmPrinter::EmitInstruction(const MachineInstr *MI) {
   AMDGPUMCInstLower MCInstLowering(OutContext);
 
+#ifdef _DEBUG
+  StringRef Err;
+  if (!TM.getInstrInfo()->verifyInstruction(MI, Err)) {
+    errs() << "Illegal instruction detected: " << Err << "\n";
+    MI->dump();
+    errs() << "Please file a bug a bugs.freedesktop.org\n";
+  }
+#endif
   if (MI->isBundle()) {
     const MachineBasicBlock *MBB = MI->getParent();
     MachineBasicBlock::const_instr_iterator I = MI;
-- 
1.8.1.5




More information about the mesa-dev mailing list