summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/ResetMachineFunctionPass.cpp
blob: 3b7729a054063602dc613e65bf46c21fe2278649 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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();
}
OpenPOWER on IntegriCloud