Skip to content

Commit 49b17a0

Browse files
authored
[MIR] Further cleanup on mutliple save/restore point support [nfc] (#153250)
Remove the type alias now that the std::variant aspect is gone, directly using std::vector in the few places that need it is more idiomatic. Move a routine from a core header to single user.
1 parent 919021b commit 49b17a0

File tree

5 files changed

+26
-25
lines changed

5 files changed

+26
-25
lines changed

llvm/include/llvm/CodeGen/MIRYamlMapping.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -644,8 +644,6 @@ struct SaveRestorePointEntry {
644644
}
645645
};
646646

647-
using SaveRestorePoints = std::vector<SaveRestorePointEntry>;
648-
649647
template <> struct MappingTraits<SaveRestorePointEntry> {
650648
static void mapping(IO &YamlIO, SaveRestorePointEntry &Entry) {
651649
YamlIO.mapRequired("point", Entry.Point);
@@ -695,8 +693,8 @@ struct MachineFrameInfo {
695693
bool HasTailCall = false;
696694
bool IsCalleeSavedInfoValid = false;
697695
unsigned LocalFrameSize = 0;
698-
SaveRestorePoints SavePoints;
699-
SaveRestorePoints RestorePoints;
696+
std::vector<SaveRestorePointEntry> SavePoints;
697+
std::vector<SaveRestorePointEntry> RestorePoints;
700698

701699
bool operator==(const MachineFrameInfo &Other) const {
702700
return IsFrameAddressTaken == Other.IsFrameAddressTaken &&

llvm/include/llvm/CodeGen/MachineFrameInfo.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -836,15 +836,6 @@ class MachineFrameInfo {
836836
RestorePoints.assign(NewRestorePoints.begin(), NewRestorePoints.end());
837837
}
838838

839-
static SmallVector<MachineBasicBlock *> constructSaveRestorePoints(
840-
ArrayRef<MachineBasicBlock *> SRPoints,
841-
const DenseMap<MachineBasicBlock *, MachineBasicBlock *> &BBMap) {
842-
SmallVector<MachineBasicBlock *> Pts;
843-
for (auto &Src : SRPoints)
844-
Pts.push_back(BBMap.find(Src)->second);
845-
return Pts;
846-
}
847-
848839
uint64_t getUnsafeStackSize() const { return UnsafeStackSize; }
849840
void setUnsafeStackSize(uint64_t Size) { UnsafeStackSize = Size; }
850841

llvm/lib/CodeGen/MIRParser/MIRParser.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class MIRParserImpl {
126126

127127
bool initializeSaveRestorePoints(
128128
PerFunctionMIParsingState &PFS,
129-
const yaml::SaveRestorePoints &YamlSRPoints,
129+
const std::vector<yaml::SaveRestorePointEntry> &YamlSRPoints,
130130
SmallVectorImpl<MachineBasicBlock *> &SaveRestorePoints);
131131

132132
bool initializeCallSiteInfo(PerFunctionMIParsingState &PFS,
@@ -1096,7 +1096,8 @@ bool MIRParserImpl::initializeConstantPool(PerFunctionMIParsingState &PFS,
10961096

10971097
// Return true if basic block was incorrectly specified in MIR
10981098
bool MIRParserImpl::initializeSaveRestorePoints(
1099-
PerFunctionMIParsingState &PFS, const yaml::SaveRestorePoints &YamlSRPoints,
1099+
PerFunctionMIParsingState &PFS,
1100+
const std::vector<yaml::SaveRestorePointEntry> &YamlSRPoints,
11001101
SmallVectorImpl<MachineBasicBlock *> &SaveRestorePoints) {
11011102
MachineBasicBlock *MBB = nullptr;
11021103
for (const yaml::SaveRestorePointEntry &Entry : YamlSRPoints) {

llvm/lib/CodeGen/MIRPrinter.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,10 @@ static void convertMJTI(ModuleSlotTracker &MST, yaml::MachineJumpTable &YamlJTI,
150150
const MachineJumpTableInfo &JTI);
151151
static void convertMFI(ModuleSlotTracker &MST, yaml::MachineFrameInfo &YamlMFI,
152152
const MachineFrameInfo &MFI);
153-
static void convertSRPoints(ModuleSlotTracker &MST,
154-
yaml::SaveRestorePoints &YamlSRPoints,
155-
ArrayRef<MachineBasicBlock *> SaveRestorePoints);
153+
static void
154+
convertSRPoints(ModuleSlotTracker &MST,
155+
std::vector<yaml::SaveRestorePointEntry> &YamlSRPoints,
156+
ArrayRef<MachineBasicBlock *> SaveRestorePoints);
156157
static void convertStackObjects(yaml::MachineFunction &YMF,
157158
const MachineFunction &MF,
158159
ModuleSlotTracker &MST, MFPrintState &State);
@@ -615,9 +616,10 @@ static void convertMCP(yaml::MachineFunction &MF,
615616
}
616617
}
617618

618-
static void convertSRPoints(ModuleSlotTracker &MST,
619-
yaml::SaveRestorePoints &YamlSRPoints,
620-
ArrayRef<MachineBasicBlock *> SRPoints) {
619+
static void
620+
convertSRPoints(ModuleSlotTracker &MST,
621+
std::vector<yaml::SaveRestorePointEntry> &YamlSRPoints,
622+
ArrayRef<MachineBasicBlock *> SRPoints) {
621623
for (const auto &MBB : SRPoints) {
622624
SmallString<16> Str;
623625
yaml::SaveRestorePointEntry Entry;

llvm/tools/llvm-reduce/ReducerWorkItem.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ static cl::opt<bool> TmpFilesAsBitcode(
6262
cl::desc("Always write temporary files as bitcode instead of textual IR"),
6363
cl::init(false), cl::cat(LLVMReduceOptions));
6464

65+
static SmallVector<MachineBasicBlock *> constructSaveRestorePoints(
66+
ArrayRef<MachineBasicBlock *> SRPoints,
67+
const DenseMap<MachineBasicBlock *, MachineBasicBlock *> &BBMap) {
68+
SmallVector<MachineBasicBlock *> Pts;
69+
for (auto &Src : SRPoints)
70+
Pts.push_back(BBMap.find(Src)->second);
71+
return Pts;
72+
}
73+
6574
static void cloneFrameInfo(
6675
MachineFrameInfo &DstMFI, const MachineFrameInfo &SrcMFI,
6776
const DenseMap<MachineBasicBlock *, MachineBasicBlock *> &Src2DstMBB) {
@@ -95,14 +104,14 @@ static void cloneFrameInfo(
95104
assert(SrcMFI.getSavePoints().size() < 2 &&
96105
"Multiple restore points not yet supported!");
97106

98-
DstMFI.setSavePoints(MachineFrameInfo::constructSaveRestorePoints(
99-
SrcMFI.getSavePoints(), Src2DstMBB));
107+
DstMFI.setSavePoints(
108+
constructSaveRestorePoints(SrcMFI.getSavePoints(), Src2DstMBB));
100109

101110
assert(SrcMFI.getRestorePoints().size() < 2 &&
102111
"Multiple restore points not yet supported!");
103112

104-
DstMFI.setRestorePoints(MachineFrameInfo::constructSaveRestorePoints(
105-
SrcMFI.getRestorePoints(), Src2DstMBB));
113+
DstMFI.setRestorePoints(
114+
constructSaveRestorePoints(SrcMFI.getRestorePoints(), Src2DstMBB));
106115

107116
auto CopyObjectProperties = [](MachineFrameInfo &DstMFI,
108117
const MachineFrameInfo &SrcMFI, int FI) {

0 commit comments

Comments
 (0)