blob: 3b7729a054063602dc613e65bf46c21fe2278649 [file] [log] [blame]
Quentin Colombet374796d2016-08-27 00:18:31 +00001//===-- ResetMachineFunctionPass.cpp - Machine Loop Invariant Code Motion Pass ---------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10//
11//===----------------------------------------------------------------------===//
12
13#include "llvm/CodeGen/Passes.h"
14#include "llvm/CodeGen/MachineFunction.h"
15#include "llvm/CodeGen/MachineFunctionPass.h"
16#include "llvm/Support/Debug.h"
17using namespace llvm;
18
19#define DEBUG_TYPE "reset-machine-function"
20
21namespace {
22 class ResetMachineFunction : public MachineFunctionPass {
23 public:
24 static char ID; // Pass identification, replacement for typeid
25 ResetMachineFunction() :
26 MachineFunctionPass(ID) {
27 }
28
29 const char *getPassName() const override {
30 return "ResetMachineFunction";
31 }
32
33 bool runOnMachineFunction(MachineFunction &MF) override {
34 if (MF.getProperties().hasProperty(
35 MachineFunctionProperties::Property::FailedISel)) {
36 DEBUG(dbgs() << "Reseting: " << MF.getName() << '\n');
37 MF.reset();
38 return true;
39 }
40 return false;
41 }
42
43 };
44} // end anonymous namespace
45
46char ResetMachineFunction::ID = 0;
47INITIALIZE_PASS(ResetMachineFunction, DEBUG_TYPE,
48 "reset machine function if ISel failed", false, false)
49
50MachineFunctionPass *
51llvm::createResetMachineFunctionPass() {
52 return new ResetMachineFunction();
53}