summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
diff options
context:
space:
mode:
authorAhmed Bougacha <ahmed.bougacha@gmail.com>2016-08-02 15:10:32 +0000
committerAhmed Bougacha <ahmed.bougacha@gmail.com>2016-08-02 15:10:32 +0000
commit24d0d4d2ecd5f2d612e3e6e9acaae1778b2f4b84 (patch)
tree61fd7e4ccc8960b70d3ab6a719e8176a709a7e07 /llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
parentad30db32e68bfd54f4185b5dd676be76444e64bd (diff)
downloadbcm5719-llvm-24d0d4d2ecd5f2d612e3e6e9acaae1778b2f4b84.tar.gz
bcm5719-llvm-24d0d4d2ecd5f2d612e3e6e9acaae1778b2f4b84.zip
[GlobalISel] Set, require, and verify Legalized MF property.
RegBankSelect and InstructionSelect run after the legalizer and require a Legalized function: check that all instructions are legal. Note that this should be in the MachineVerifier, but it can't use the MachineLegalizer as it's currently in the separate GlobalISel library. Note that the RegBankSelect verifier checks have the same layering problem, but we only use inline methods so end up not needing to link against the GlobalISel library. llvm-svn: 277472
Diffstat (limited to 'llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp')
-rw-r--r--llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp b/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
index 3279d13ed76..92a755c9104 100644
--- a/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
@@ -14,6 +14,7 @@
#include "llvm/ADT/PostOrderIterator.h"
#include "llvm/ADT/Twine.h"
#include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
+#include "llvm/CodeGen/GlobalISel/MachineLegalizer.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/IR/Function.h"
#include "llvm/Support/CommandLine.h"
@@ -51,6 +52,19 @@ bool InstructionSelect::runOnMachineFunction(MachineFunction &MF) {
// other MF/MFI fields we need to initialize.
#ifndef NDEBUG
+ // Check that our input is fully legal: we require the function to have the
+ // Legalized property, so it should be.
+ // FIXME: This should be in the MachineVerifier, but it can't use the
+ // MachineLegalizer as it's currently in the separate GlobalISel library.
+ // The RegBankSelected property is already checked in the verifier. Note
+ // that it has the same layering problem, but we only use inline methods so
+ // end up not needing to link against the GlobalISel library.
+ if (const MachineLegalizer *MLI = MF.getSubtarget().getMachineLegalizer())
+ for (const MachineBasicBlock &MBB : MF)
+ for (const MachineInstr &MI : MBB)
+ if (isPreISelGenericOpcode(MI.getOpcode()) && !MLI->isLegal(MI))
+ reportSelectionError(MI, "Instruction is not legal");
+
// FIXME: We could introduce new blocks and will need to fix the outer loop.
// Until then, keep track of the number of blocks to assert that we don't.
const size_t NumBlocks = MF.size();
OpenPOWER on IntegriCloud