Add a few simple MachineVerifier checks for MachineMemOperands.
authorDan Gohman <gohman@apple.com>
Wed, 7 Oct 2009 17:36:00 +0000 (17:36 +0000)
committerDan Gohman <gohman@apple.com>
Wed, 7 Oct 2009 17:36:00 +0000 (17:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83474 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/MachineVerifier.cpp

index f851dcf8881346239b1f3e9babc46d585485840e..18a3ead3bc1801a4ae269ebfc60259e1cc904140 100644 (file)
@@ -27,6 +27,7 @@
 #include "llvm/CodeGen/LiveVariables.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
+#include "llvm/CodeGen/MachineMemOperand.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/CodeGen/Passes.h"
 #include "llvm/Target/TargetMachine.h"
@@ -457,6 +458,15 @@ void MachineVerifier::visitMachineInstrBefore(const MachineInstr *MI) {
     *OS << TI.getNumOperands() << " operands expected, but "
         << MI->getNumExplicitOperands() << " given.\n";
   }
+
+  // Check the MachineMemOperands for basic consistency.
+  for (MachineInstr::mmo_iterator I = MI->memoperands_begin(),
+       E = MI->memoperands_end(); I != E; ++I) {
+    if ((*I)->isLoad() && !TI.mayLoad())
+      report("Missing mayLoad flag", MI);
+    if ((*I)->isStore() && !TI.mayStore())
+      report("Missing mayStore flag", MI);
+  }
 }
 
 void