LLVM
4.0.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
llvm.src
lib
CodeGen
ResetMachineFunctionPass.cpp
Go to the documentation of this file.
1
//===-- ResetMachineFunctionPass.cpp - Reset Machine Function ----*- C++ -*-==//
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
/// \file
10
/// This file implements a pass that will conditionally reset a machine
11
/// function as if it was just created. This is used to provide a fallback
12
/// mechanism when GlobalISel fails, thus the condition for the reset to
13
/// happen is that the MachineFunction has the FailedISel property.
14
//===----------------------------------------------------------------------===//
15
16
#include "
llvm/ADT/Statistic.h
"
17
#include "
llvm/CodeGen/Passes.h
"
18
#include "
llvm/CodeGen/MachineFunction.h
"
19
#include "
llvm/CodeGen/MachineFunctionPass.h
"
20
#include "
llvm/IR/DiagnosticInfo.h
"
21
#include "
llvm/Support/Debug.h
"
22
using namespace
llvm;
23
24
#define DEBUG_TYPE "reset-machine-function"
25
26
STATISTIC
(NumFunctionsReset,
"Number of functions reset"
);
27
28
namespace
{
29
class
ResetMachineFunction :
public
MachineFunctionPass
{
30
/// Tells whether or not this pass should emit a fallback
31
/// diagnostic when it resets a function.
32
bool
EmitFallbackDiag;
33
34
public
:
35
static
char
ID
;
// Pass identification, replacement for typeid
36
ResetMachineFunction(
bool
EmitFallbackDiag =
false
)
37
:
MachineFunctionPass
(
ID
), EmitFallbackDiag(EmitFallbackDiag) {}
38
39
StringRef
getPassName()
const override
{
return
"ResetMachineFunction"
; }
40
41
bool
runOnMachineFunction(
MachineFunction
&MF)
override
{
42
if
(MF.
getProperties
().
hasProperty
(
43
MachineFunctionProperties::Property::FailedISel
)) {
44
DEBUG
(
dbgs
() <<
"Reseting: "
<< MF.
getName
() <<
'\n'
);
45
++NumFunctionsReset;
46
MF.
reset
();
47
if
(EmitFallbackDiag) {
48
const
Function
&
F
= *MF.
getFunction
();
49
DiagnosticInfoISelFallback
DiagFallback(F);
50
F.
getContext
().
diagnose
(DiagFallback);
51
}
52
return
true
;
53
}
54
return
false
;
55
}
56
57
};
58
}
// end anonymous namespace
59
60
char
ResetMachineFunction::ID
= 0;
61
INITIALIZE_PASS
(ResetMachineFunction,
DEBUG_TYPE
,
62
"reset machine function if ISel failed"
,
false
,
false
)
63
64
MachineFunctionPass
*
65
llvm::
createResetMachineFunctionPass
(
bool
EmitFallbackDiag =
false
) {
66
return
new
ResetMachineFunction(EmitFallbackDiag);
67
}
llvm::DiagnosticInfoISelFallback
Diagnostic information for ISel fallback path.
Definition:
DiagnosticInfo.h:753
DiagnosticInfo.h
llvm::Function::getContext
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
Definition:
Function.cpp:226
llvm::STATISTIC
STATISTIC(NumFunctions,"Total number of functions")
llvm::MachineFunctionProperties::hasProperty
bool hasProperty(Property P) const
Definition:
MachineFunction.h:137
llvm::MachineFunction
Definition:
MachineFunction.h:197
Debug.h
INITIALIZE_PASS
INITIALIZE_PASS(ResetMachineFunction, DEBUG_TYPE,"reset machine function if ISel failed", false, false) MachineFunctionPass *llvm
Definition:
ResetMachineFunctionPass.cpp:61
DEBUG_TYPE
#define DEBUG_TYPE
Definition:
ResetMachineFunctionPass.cpp:24
llvm::MachineFunction::getFunction
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
Definition:
MachineFunction.h:354
llvm::Function
Definition:
Function.h:48
Statistic.h
llvm::MachineFunctionProperties::Property::FailedISel
llvm::createResetMachineFunctionPass
MachineFunctionPass * createResetMachineFunctionPass(bool EmitFallbackDiag)
This pass resets a MachineFunction when it has the FailedISel property as if it was just created...
MachineFunction.h
llvm::MachineFunctionPass
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Definition:
MachineFunctionPass.h:31
llvm::MachineFunction::getProperties
const MachineFunctionProperties & getProperties() const
Get the function properties.
Definition:
MachineFunction.h:458
F
#define F(x, y, z)
Definition:
MD5.cpp:51
llvm::Intrinsic::ID
ID
Definition:
Intrinsics.h:37
false
Function Alias Analysis false
Definition:
AliasAnalysis.cpp:586
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition:
Debug.cpp:132
llvm::MachineFunction::reset
void reset()
Reset the instance as if it was just created.
Definition:
MachineFunction.h:339
llvm::LLVMContext::diagnose
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
Definition:
LLVMContext.cpp:196
MachineFunctionPass.h
DEBUG
#define DEBUG(X)
Definition:
Debug.h:100
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:
StringRef.h:47
llvm::MachineFunction::getName
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
Definition:
MachineFunction.cpp:421
Passes.h
Generated on Wed Mar 8 2017 17:21:55 for LLVM by
1.8.6