LLVM: lib/CodeGen/ResetMachineFunctionPass.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

26using namespace llvm;

27

28#define DEBUG_TYPE "reset-machine-function"

29

30STATISTIC(NumFunctionsReset, "Number of functions reset");

31STATISTIC(NumFunctionsVisited, "Number of functions visited");

32

33namespace {

35

36

37 bool EmitFallbackDiag;

38

39 bool AbortOnFailedISel;

40

41 public:

42 static char ID;

43 ResetMachineFunction(bool EmitFallbackDiag = false,

44 bool AbortOnFailedISel = false)

46 AbortOnFailedISel(AbortOnFailedISel) {}

47

48 StringRef getPassName() const override { return "ResetMachineFunction"; }

49

50 void getAnalysisUsage(AnalysisUsage &AU) const override {

53 }

54

55 bool runOnMachineFunction(MachineFunction &MF) override {

56 ++NumFunctionsVisited;

57

58

59

60 auto ClearVRegTypesOnReturn =

62

64 if (AbortOnFailedISel)

67 ++NumFunctionsReset;

70

71 const TargetMachine &TM = MF.getTarget();

72

74

75 if (EmitFallbackDiag) {

77 DiagnosticInfoISelFallback DiagFallback(F);

78 F.getContext().diagnose(DiagFallback);

79 }

80 return true;

81 }

82 return false;

83 }

84

85 };

86}

87

88char ResetMachineFunction::ID = 0;

90 "Reset machine function if ISel failed", false, false)

91

94 bool AbortOnFailedISel = false) {

95 return new ResetMachineFunction(EmitFallbackDiag, AbortOnFailedISel);

96}

#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)

This file defines the make_scope_exit function, which executes user-defined cleanup logic at scope ex...

This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...

#define STATISTIC(VARNAME, DESC)

AnalysisUsage & addPreserved()

Add the specified Pass class to the set of analyses preserved by this pass.

MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...

void getAnalysisUsage(AnalysisUsage &AU) const override

getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.

const TargetSubtargetInfo & getSubtarget() const

getSubtarget - Return the subtarget for which this machine code is being compiled.

StringRef getName() const

getName - Return the name of the corresponding LLVM function.

void initTargetMachineFunctionInfo(const TargetSubtargetInfo &STI)

Initialize the target specific MachineFunctionInfo.

MachineRegisterInfo & getRegInfo()

getRegInfo - Return information about the registers currently in use.

Function & getFunction()

Return the LLVM function that this machine code represents.

const MachineFunctionProperties & getProperties() const

Get the function properties.

void reset()

Reset the instance as if it was just created.

const TargetMachine & getTarget() const

getTarget - Return the target machine this machine code is compiled with

LLVM_ABI void clearVirtRegTypes()

Remove all types associated to virtual registers (after instruction selection and constraining of all...

virtual void registerMachineRegisterInfoCallback(MachineFunction &MF) const

unsigned ID

LLVM IR allows to use arbitrary numbers as calling convention identifiers.

This is an optimization pass for GlobalISel generic memory operations.

detail::scope_exit< std::decay_t< Callable > > make_scope_exit(Callable &&F)

LLVM_ABI MachineFunctionPass * createResetMachineFunctionPass(bool EmitFallbackDiag, bool AbortOnFailedISel)

This pass resets a MachineFunction when it has the FailedISel property as if it was just created.

LLVM_ABI raw_ostream & dbgs()

dbgs() - This returns a reference to a raw_ostream for debugging messages.

LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)