1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 18:42:46 +02:00

VirtRegMap: Add pass option to not clear virt regs

In a future change it will be possible to run register
allocation with a specific set of register classes,
so some of the remaining virtual registers will still
be meaningful.
This commit is contained in:
Matt Arsenault 2018-10-25 14:45:55 -07:00
parent f725cb4c03
commit 4bfb34b180
2 changed files with 21 additions and 7 deletions

View File

@ -150,6 +150,7 @@ namespace llvm {
/// VirtRegRewriter pass. Rewrite virtual registers to physical registers as
/// assigned in VirtRegMap.
extern char &VirtRegRewriterID;
FunctionPass *createVirtRegRewriter(bool ClearVirtRegs = true);
/// UnreachableMachineBlockElimination - This pass removes unreachable
/// machine basic blocks.

View File

@ -181,6 +181,7 @@ class VirtRegRewriter : public MachineFunctionPass {
SlotIndexes *Indexes;
LiveIntervals *LIS;
VirtRegMap *VRM;
bool ClearVirtRegs;
void rewrite();
void addMBBLiveIns();
@ -192,16 +193,21 @@ class VirtRegRewriter : public MachineFunctionPass {
public:
static char ID;
VirtRegRewriter() : MachineFunctionPass(ID) {}
VirtRegRewriter(bool ClearVirtRegs_ = true) :
MachineFunctionPass(ID),
ClearVirtRegs(ClearVirtRegs_) {}
void getAnalysisUsage(AnalysisUsage &AU) const override;
bool runOnMachineFunction(MachineFunction&) override;
MachineFunctionProperties getSetProperties() const override {
return MachineFunctionProperties().set(
if (ClearVirtRegs) {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs);
}
return MachineFunctionProperties();
}
};
@ -257,10 +263,13 @@ bool VirtRegRewriter::runOnMachineFunction(MachineFunction &fn) {
// Write out new DBG_VALUE instructions.
getAnalysis<LiveDebugVariables>().emitDebugValues(VRM);
// All machine operands and other references to virtual registers have been
// replaced. Remove the virtual registers and release all the transient data.
VRM->clearAllVirt();
MRI->clearVirtRegs();
if (ClearVirtRegs) {
// All machine operands and other references to virtual registers have been
// replaced. Remove the virtual registers and release all the transient data.
VRM->clearAllVirt();
MRI->clearVirtRegs();
}
return true;
}
@ -591,3 +600,7 @@ void VirtRegRewriter::rewrite() {
}
}
}
FunctionPass *llvm::createVirtRegRewriter(bool ClearVirtRegs) {
return new VirtRegRewriter(ClearVirtRegs);
}