LLVM: lib/CodeGen/RemoveLoadsIntoFakeUses.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
38
39using namespace llvm;
40
41#define DEBUG_TYPE "remove-loads-into-fake-uses"
42
43STATISTIC(NumLoadsDeleted, "Number of dead load instructions deleted");
44STATISTIC(NumFakeUsesDeleted, "Number of FAKE_USE instructions deleted");
45
47public:
49
54
59
63
65 return "Remove Loads Into Fake Uses";
66 }
67
69};
70
74
77
79 "Remove Loads Into Fake Uses", false, false)
82
89
94
97
100 return PA;
101}
102
104
105
107 return false;
108
110 return false;
111
112 bool AnyChanges = false;
113
119
123 RegFakeUses.clear();
125
127 if (MI.isFakeUse()) {
128 if (MI.getNumOperands() == 0 || .getOperand(0).isReg())
129 continue;
130
131
133
134
135 continue;
136 }
137
138
139
140 if (MI.getRestoreSize(TII)) {
141 Register Reg = MI.getOperand(0).getReg();
142
144 continue;
145
146
147
148
149
150
151
154 if (FakeUse->readsRegister(Reg, TRI)) {
155 FakeUsesToDelete.insert(FakeUse);
156 RegFakeUses.erase(&FakeUse);
157 }
158 }
159 if (!FakeUsesToDelete.empty()) {
160 LLVM_DEBUG(dbgs() << "RemoveLoadsIntoFakeUses: DELETING: " << MI);
161
162
163
164 MI.eraseFromParent();
165 AnyChanges = true;
166 ++NumLoadsDeleted;
167 for (MachineInstr *FakeUse : FakeUsesToDelete) {
169 << "RemoveLoadsIntoFakeUses: DELETING: " << *FakeUse);
170 FakeUse->eraseFromParent();
171 }
172 NumFakeUsesDeleted += FakeUsesToDelete.size();
173 }
174 continue;
175 }
176
177
178
179
180 if (!RegFakeUses.empty()) {
182 if (!MO.isReg())
183 continue;
185
186
187
189 if (FakeUse->readsRegister(Reg, TRI))
190 RegFakeUses.erase(&FakeUse);
191 }
192 }
194 }
195 }
196
197 return AnyChanges;
198}
unsigned const MachineRegisterInfo * MRI
const TargetInstrInfo & TII
Register const TargetRegisterInfo * TRI
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(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)
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
Definition RemoveLoadsIntoFakeUses.cpp:83
RemoveLoadsIntoFakeUsesLegacy()
Definition RemoveLoadsIntoFakeUses.cpp:50
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
Definition RemoveLoadsIntoFakeUses.cpp:64
MachineFunctionProperties getRequiredProperties() const override
Definition RemoveLoadsIntoFakeUses.cpp:60
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Definition RemoveLoadsIntoFakeUses.cpp:55
static char ID
Definition RemoveLoadsIntoFakeUses.cpp:48
Represent the analysis usage information of a pass.
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.
bool skipFunction(const Function &F) const
Optional passes call this function to check whether the pass should be skipped.
A set of physical registers with utility functions to track liveness when walking backward/forward th...
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.
bool available(const MachineRegisterInfo &MRI, MCRegister Reg) const
Returns true if register Reg and no aliasing register is in 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.
An RAII based helper class to modify MachineFunctionProperties when running pass.
MachineFunctionPass(char &ID)
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Properties which a MachineFunction may have at a given point in time.
bool useDebugInstrRef() const
Returns true if the function's variable locations are tracked with instruction referencing.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
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.
Wrapper class representing virtual and physical registers.
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Definition RemoveLoadsIntoFakeUses.cpp:91
Implements a dense probed hash-table based set with some number of buckets stored inline.
iterator erase(const_iterator CI)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
TargetInstrInfo - Interface to description of machine instruction set.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
TargetSubtargetInfo - Generic base class for all target subtargets.
std::pair< iterator, bool > insert(const ValueT &V)
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...
LLVM_ABI char & RemoveLoadsIntoFakeUsesID
RemoveLoadsIntoFakeUses pass.
Definition RemoveLoadsIntoFakeUses.cpp:76
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 void initializeRemoveLoadsIntoFakeUsesLegacyPass(PassRegistry &)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool run(MachineFunction &MF)
Definition RemoveLoadsIntoFakeUses.cpp:103