LLVM: lib/CodeGen/RegUsageInfoPropagate.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
34
35using namespace llvm;
36
37#define DEBUG_TYPE "ip-regalloc"
38
39#define RUIP_NAME "Register Usage Information Propagation"
40
41namespace {
42
43class RegUsageInfoPropagation {
44public:
46 : PRUI(PRUI) {}
47
49
50private:
52
56 ->getRegInfo().getTargetRegisterInfo()
57 ->getNumRegs())
58 && "expected register mask size");
60 if (MO.isRegMask())
61 MO.setRegMask(RegMask.data());
62 }
63 }
64};
65
67public:
68 static char ID;
72 }
73
75
77
82 }
83};
84
85}
86
92
93char RegUsageInfoPropagationLegacy::ID = 0;
94
95
99 if (MO.isGlobal())
100 return dyn_cast(MO.getGlobal());
101
102 if (MO.isSymbol())
103 return M.getFunction(MO.getSymbolName());
104 }
105
106 return nullptr;
107}
108
109bool RegUsageInfoPropagationLegacy::runOnMachineFunction(MachineFunction &MF) {
111 &getAnalysis().getPRUI();
112
113 RegUsageInfoPropagation RUIP(PRUI);
114 return RUIP.run(MF);
115}
116
122 .getCachedResult(MFA);
123 assert(PRUI && "PhysicalRegisterUsageAnalysis not available");
124 RegUsageInfoPropagation(PRUI).run(MF);
126}
127
130
132 << " ++++++++++++++++++++ \n");
134
137 return false;
138
139 bool Changed = false;
140
143 if (.isCall())
144 continue;
147 << "Call Instruction Before Register Usage Info Propagation : \n"
148 << MI << "\n");
149
150 auto UpdateRegMask = [&](const Function &F) {
152 if (RegMask.empty())
153 return;
154 setRegMask(MI, RegMask);
155 Changed = true;
156 };
157
159 if (F->isDefinitionExact()) {
160 UpdateRegMask(*F);
161 } else {
162 LLVM_DEBUG(dbgs() << "Function definition is not exact\n");
163 }
164 } else {
165 LLVM_DEBUG(dbgs() << "Failed to find call target function\n");
166 }
167
170 << "Call Instruction After Register Usage Info Propagation : \n"
171 << MI << '\n');
172 }
173 }
174
176 dbgs() << " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
177 "++++++ \n");
178 return Changed;
179}
180
182 return new RegUsageInfoPropagationLegacy();
183}
Module.h This file contains the declarations for the Module class.
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
static const Function * findCalledFunction(const Module &M, const MachineInstr &MI)
This pass is required to take advantage of the interprocedural register allocation infrastructure.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A container for analyses that lazily runs them and caches their results.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
void setPreservesAll()
Set by analyses that do not transform their input at all.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
bool empty() const
empty - Check if the array is empty.
FunctionPass class - This class is used to implement most global optimizations.
Module * getParent()
Get the module that this global value is contained inside of...
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
bool hasCalls() const
Return true if the current function has any function calls.
bool hasTailCall() const
Returns true if the function contains a tail call.
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.
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
Function & getFunction()
Return the LLVM function that this machine code represents.
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
static unsigned getRegMaskSize(unsigned NumRegs)
Returns number of elements needed for a regmask array.
A Module instance is used to store all the information related to an LLVM module.
An analysis over an "inner" IR unit that provides access to an analysis manager over a "outer" IR uni...
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
ArrayRef< uint32_t > getRegUsageInfo(const Function &FP)
To query stored RegMask for given Function *, it will returns ane empty array if function is not know...
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 run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
A global registry used in conjunction with static constructors to make pluggable components (like tar...
StringRef - Represent a constant reference to a string, i.e.
Pass manager infrastructure for declaring and invalidating analyses.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FunctionPass * createRegUsageInfoPropPass()
Return a MachineFunction pass that identifies call sites and propagates register usage information of...
void initializeRegUsageInfoPropagationLegacyPass(PassRegistry &)