diff options
author | Quentin Colombet <qcolombet@apple.com> | 2016-08-27 00:18:31 +0000 |
---|---|---|
committer | Quentin Colombet <qcolombet@apple.com> | 2016-08-27 00:18:31 +0000 |
commit | 374796d67853db94589da4aec48443e28e1a1590 (patch) | |
tree | 8f9ee74beac7679032a8f393856ad1eca0e876b3 /llvm/lib/CodeGen/ResetMachineFunctionPass.cpp | |
parent | a94caa56736debed318eaf4dd20632d2132ebdf8 (diff) | |
download | bcm5719-llvm-374796d67853db94589da4aec48443e28e1a1590.tar.gz bcm5719-llvm-374796d67853db94589da4aec48443e28e1a1590.zip |
[GlobalISel] Add a fallback path to SDISel.
When global-isel fails on a MachineFunction MF, MF will be cleaned up
and given to SDISel.
Thanks to this fallback, we can already perform correctness test even if
we support only a small portion of the functions in a test.
llvm-svn: 279891
Diffstat (limited to 'llvm/lib/CodeGen/ResetMachineFunctionPass.cpp')
-rw-r--r-- | llvm/lib/CodeGen/ResetMachineFunctionPass.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/ResetMachineFunctionPass.cpp b/llvm/lib/CodeGen/ResetMachineFunctionPass.cpp new file mode 100644 index 00000000000..3b7729a0540 --- /dev/null +++ b/llvm/lib/CodeGen/ResetMachineFunctionPass.cpp @@ -0,0 +1,53 @@ +//===-- ResetMachineFunctionPass.cpp - Machine Loop Invariant Code Motion Pass ---------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// +//===----------------------------------------------------------------------===// + +#include "llvm/CodeGen/Passes.h" +#include "llvm/CodeGen/MachineFunction.h" +#include "llvm/CodeGen/MachineFunctionPass.h" +#include "llvm/Support/Debug.h" +using namespace llvm; + +#define DEBUG_TYPE "reset-machine-function" + +namespace { + class ResetMachineFunction : public MachineFunctionPass { + public: + static char ID; // Pass identification, replacement for typeid + ResetMachineFunction() : + MachineFunctionPass(ID) { + } + + const char *getPassName() const override { + return "ResetMachineFunction"; + } + + bool runOnMachineFunction(MachineFunction &MF) override { + if (MF.getProperties().hasProperty( + MachineFunctionProperties::Property::FailedISel)) { + DEBUG(dbgs() << "Reseting: " << MF.getName() << '\n'); + MF.reset(); + return true; + } + return false; + } + + }; +} // end anonymous namespace + +char ResetMachineFunction::ID = 0; +INITIALIZE_PASS(ResetMachineFunction, DEBUG_TYPE, + "reset machine function if ISel failed", false, false) + +MachineFunctionPass * +llvm::createResetMachineFunctionPass() { + return new ResetMachineFunction(); +} |