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

1

2

3

4

5

6

7

8

9

10

11

12

24

25using namespace llvm;

26

27#define DEBUG_TYPE "dead-mi-elimination"

28

29STATISTIC(NumDeletes, "Number of dead instructions deleted");

30

31namespace {

32class DeadMachineInstructionElimImpl {

36

37public:

39

40private:

42};

43

45public:

46 static char ID;

47

48 DeadMachineInstructionElim() : MachineFunctionPass(ID) {

50 }

51

52 bool runOnMachineFunction(MachineFunction &MF) override {

54 return false;

55 return DeadMachineInstructionElimImpl().runImpl(MF);

56 }

57

58 void getAnalysisUsage(AnalysisUsage &AU) const override {

61 }

62};

63}

64

68 if (!DeadMachineInstructionElimImpl().runImpl(MF))

72 return PA;

73}

74

75char DeadMachineInstructionElim::ID = 0;

77

79 "Remove dead machine instructions", false, false)

80

82 MRI = &MF.getRegInfo();

83

85 TII = ST.getInstrInfo();

87

88 bool AnyChanges = eliminateDeadMI(MF);

89 while (AnyChanges && eliminateDeadMI(MF))

90 ;

91 return AnyChanges;

92}

93

94bool DeadMachineInstructionElimImpl::eliminateDeadMI(MachineFunction &MF) {

95 bool AnyChanges = false;

96

97

98

99

102

103

104

106

108 LLVM_DEBUG(dbgs() << "DeadMachineInstructionElim: DELETING: " << MI);

109

110

111

112 MI.eraseFromParent();

113 AnyChanges = true;

114 ++NumDeletes;

115 continue;

116 }

118 }

119 }

121 return AnyChanges;

122}

unsigned const MachineRegisterInfo * MRI

const TargetInstrInfo & TII

static bool runImpl(Function &F, const TargetLowering &TLI, const LibcallLoweringInfo &Libcalls, AssumptionCache *AC)

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

This file builds on the ADT/GraphTraits.h file to build a generic graph post order iterator.

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

#define STATISTIC(VARNAME, DESC)

LLVM_ABI void setPreservesCFG()

This function should be called by the pass, iff they do not:

Represents analyses that only rely on functions' control flow.

PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)

Definition DeadMachineInstructionElim.cpp:66

A set of physical registers with utility functions to track liveness when walking backward/forward th...

void clear()

Clears the set.

void stepBackward(const MachineInstr &MI)

Simulates liveness when stepping backwards over an instruction(bundle).

void init(const TargetRegisterInfo &TRI)

(re-)initializes and clears the set.

void addLiveOuts(const MachineBasicBlock &MBB)

Adds all live-out registers of basic block MBB.

A set of register units used to track register liveness.

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.

Function & getFunction()

Return the LLVM function that this machine code represents.

Representation of each machine instruction.

MachineRegisterInfo - Keep track of information for virtual and physical registers,...

static LLVM_ABI PassRegistry * getPassRegistry()

getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...

A set of analyses that are preserved following a run of a transformation pass.

static PreservedAnalyses all()

Construct a special preserved set that preserves all passes.

PreservedAnalyses & preserveSet()

Mark an analysis set as preserved.

TargetInstrInfo - Interface to description of machine instruction set.

TargetSubtargetInfo - Generic base class for all target subtargets.

This is an optimization pass for GlobalISel generic memory operations.

iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)

Make a range that does early increment to allow mutation of the underlying range without disrupting i...

iterator_range< po_iterator< T > > post_order(const T &G)

AnalysisManager< MachineFunction > MachineFunctionAnalysisManager

LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()

Returns the minimum set of Analyses that all machine function passes must preserve.

auto reverse(ContainerTy &&C)

LLVM_ABI raw_ostream & dbgs()

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

LLVM_ABI void initializeDeadMachineInstructionElimPass(PassRegistry &)

LLVM_ABI char & DeadMachineInstructionElimID

DeadMachineInstructionElim - This pass removes dead machine instructions.

Definition DeadMachineInstructionElim.cpp:76