-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[CodeGen] Preserved additional analyses in StackSlotColoring pass. #93779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
dc21436
c8079d7
c56007d
eb410b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
#include "llvm/ADT/BitVector.h" | ||
#include "llvm/ADT/SmallVector.h" | ||
#include "llvm/ADT/Statistic.h" | ||
#include "llvm/CodeGen/LiveDebugVariables.h" | ||
#include "llvm/CodeGen/LiveInterval.h" | ||
#include "llvm/CodeGen/LiveIntervalUnion.h" | ||
#include "llvm/CodeGen/LiveIntervals.h" | ||
|
@@ -64,6 +65,7 @@ namespace { | |
MachineFrameInfo *MFI = nullptr; | ||
const TargetInstrInfo *TII = nullptr; | ||
const MachineBlockFrequencyInfo *MBFI = nullptr; | ||
SlotIndexes *Indexes = nullptr; | ||
|
||
// SSIntervals - Spill slot intervals. | ||
std::vector<LiveInterval*> SSIntervals; | ||
|
@@ -152,6 +154,14 @@ namespace { | |
AU.addRequired<MachineBlockFrequencyInfo>(); | ||
AU.addPreserved<MachineBlockFrequencyInfo>(); | ||
AU.addPreservedID(MachineDominatorsID); | ||
|
||
// In some Target's pipeline, register allocation (RA) might be | ||
// split into multiple phases based on register class. So, this pass | ||
// may be invoked multiple times requiring it to save these analyses to be | ||
// used by RA later. | ||
AU.addPreserved<LiveIntervals>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you need to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "addPreserved < SlotIndexes > " was already there before. As for LiveIntervals, it would be needed to be preserved for maybe the upcoming regAlloc pass for remaining register classes, else it is being re-computed, which somehow creating problem. |
||
AU.addPreserved<LiveDebugVariables>(); | ||
|
||
MachineFunctionPass::getAnalysisUsage(AU); | ||
} | ||
|
||
|
@@ -496,8 +506,11 @@ bool StackSlotColoring::RemoveDeadStores(MachineBasicBlock* MBB) { | |
++I; | ||
} | ||
|
||
for (MachineInstr *MI : toErase) | ||
for (MachineInstr *MI : toErase) { | ||
if (Indexes) | ||
Indexes->removeMachineInstrFromMaps(*MI); | ||
MI->eraseFromParent(); | ||
} | ||
|
||
return changed; | ||
} | ||
|
@@ -515,6 +528,7 @@ bool StackSlotColoring::runOnMachineFunction(MachineFunction &MF) { | |
TII = MF.getSubtarget().getInstrInfo(); | ||
LS = &getAnalysis<LiveStacks>(); | ||
MBFI = &getAnalysis<MachineBlockFrequencyInfo>(); | ||
Indexes = &getAnalysis<SlotIndexes>(); | ||
|
||
bool Changed = false; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could probably avoid the include by using the PassID
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For that, "char &llvm::passID = pass::ID", need to be added in the respective pass (not presently there in LiveDebugVariables.cpp), followed by exposing it via extern in Passes.h. So, I think this is better option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But those should be there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I was going through the Codegen passes, while most of them have it, others don't. What should be the right practice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They all should (but the PassID will go away in new PM so it's probably not worth fixing all of the missing instances)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, what should be supposed to be my final take on it!