[llvm] 49b17a0 - [MIR] Further cleanup on mutliple save/restore point support [nfc] (#153250)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 12 14:16:44 PDT 2025
Author: Philip Reames
Date: 2025-08-12T14:16:41-07:00
New Revision: 49b17a0c1c3cead80c1ee5f6e054409c85e7ef97
URL: https://github.com/llvm/llvm-project/commit/49b17a0c1c3cead80c1ee5f6e054409c85e7ef97
DIFF: https://github.com/llvm/llvm-project/commit/49b17a0c1c3cead80c1ee5f6e054409c85e7ef97.diff
LOG: [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.
Added:
Modified:
llvm/include/llvm/CodeGen/MIRYamlMapping.h
llvm/include/llvm/CodeGen/MachineFrameInfo.h
llvm/lib/CodeGen/MIRParser/MIRParser.cpp
llvm/lib/CodeGen/MIRPrinter.cpp
llvm/tools/llvm-reduce/ReducerWorkItem.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/MIRYamlMapping.h b/llvm/include/llvm/CodeGen/MIRYamlMapping.h
index f394f813ed3a9..a91c26ee1122a 100644
--- a/llvm/include/llvm/CodeGen/MIRYamlMapping.h
+++ b/llvm/include/llvm/CodeGen/MIRYamlMapping.h
@@ -644,8 +644,6 @@ struct SaveRestorePointEntry {
}
};
-using SaveRestorePoints = std::vector<SaveRestorePointEntry>;
-
template <> struct MappingTraits<SaveRestorePointEntry> {
static void mapping(IO &YamlIO, SaveRestorePointEntry &Entry) {
YamlIO.mapRequired("point", Entry.Point);
@@ -695,8 +693,8 @@ struct MachineFrameInfo {
bool HasTailCall = false;
bool IsCalleeSavedInfoValid = false;
unsigned LocalFrameSize = 0;
- SaveRestorePoints SavePoints;
- SaveRestorePoints RestorePoints;
+ std::vector<SaveRestorePointEntry> SavePoints;
+ std::vector<SaveRestorePointEntry> RestorePoints;
bool operator==(const MachineFrameInfo &Other) const {
return IsFrameAddressTaken == Other.IsFrameAddressTaken &&
diff --git a/llvm/include/llvm/CodeGen/MachineFrameInfo.h b/llvm/include/llvm/CodeGen/MachineFrameInfo.h
index f4f658f7d7155..e666001035deb 100644
--- a/llvm/include/llvm/CodeGen/MachineFrameInfo.h
+++ b/llvm/include/llvm/CodeGen/MachineFrameInfo.h
@@ -836,15 +836,6 @@ class MachineFrameInfo {
RestorePoints.assign(NewRestorePoints.begin(), NewRestorePoints.end());
}
- static SmallVector<MachineBasicBlock *> constructSaveRestorePoints(
- ArrayRef<MachineBasicBlock *> SRPoints,
- const DenseMap<MachineBasicBlock *, MachineBasicBlock *> &BBMap) {
- SmallVector<MachineBasicBlock *> Pts;
- for (auto &Src : SRPoints)
- Pts.push_back(BBMap.find(Src)->second);
- return Pts;
- }
-
uint64_t getUnsafeStackSize() const { return UnsafeStackSize; }
void setUnsafeStackSize(uint64_t Size) { UnsafeStackSize = Size; }
diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
index 8b6b53e5a4fc0..bb70e7805e818 100644
--- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
@@ -126,7 +126,7 @@ class MIRParserImpl {
bool initializeSaveRestorePoints(
PerFunctionMIParsingState &PFS,
- const yaml::SaveRestorePoints &YamlSRPoints,
+ const std::vector<yaml::SaveRestorePointEntry> &YamlSRPoints,
SmallVectorImpl<MachineBasicBlock *> &SaveRestorePoints);
bool initializeCallSiteInfo(PerFunctionMIParsingState &PFS,
@@ -1096,7 +1096,8 @@ bool MIRParserImpl::initializeConstantPool(PerFunctionMIParsingState &PFS,
// Return true if basic block was incorrectly specified in MIR
bool MIRParserImpl::initializeSaveRestorePoints(
- PerFunctionMIParsingState &PFS, const yaml::SaveRestorePoints &YamlSRPoints,
+ PerFunctionMIParsingState &PFS,
+ const std::vector<yaml::SaveRestorePointEntry> &YamlSRPoints,
SmallVectorImpl<MachineBasicBlock *> &SaveRestorePoints) {
MachineBasicBlock *MBB = nullptr;
for (const yaml::SaveRestorePointEntry &Entry : YamlSRPoints) {
diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp
index 6280f24301696..7cc91925793a1 100644
--- a/llvm/lib/CodeGen/MIRPrinter.cpp
+++ b/llvm/lib/CodeGen/MIRPrinter.cpp
@@ -150,9 +150,10 @@ static void convertMJTI(ModuleSlotTracker &MST, yaml::MachineJumpTable &YamlJTI,
const MachineJumpTableInfo &JTI);
static void convertMFI(ModuleSlotTracker &MST, yaml::MachineFrameInfo &YamlMFI,
const MachineFrameInfo &MFI);
-static void convertSRPoints(ModuleSlotTracker &MST,
- yaml::SaveRestorePoints &YamlSRPoints,
- ArrayRef<MachineBasicBlock *> SaveRestorePoints);
+static void
+convertSRPoints(ModuleSlotTracker &MST,
+ std::vector<yaml::SaveRestorePointEntry> &YamlSRPoints,
+ ArrayRef<MachineBasicBlock *> SaveRestorePoints);
static void convertStackObjects(yaml::MachineFunction &YMF,
const MachineFunction &MF,
ModuleSlotTracker &MST, MFPrintState &State);
@@ -615,9 +616,10 @@ static void convertMCP(yaml::MachineFunction &MF,
}
}
-static void convertSRPoints(ModuleSlotTracker &MST,
- yaml::SaveRestorePoints &YamlSRPoints,
- ArrayRef<MachineBasicBlock *> SRPoints) {
+static void
+convertSRPoints(ModuleSlotTracker &MST,
+ std::vector<yaml::SaveRestorePointEntry> &YamlSRPoints,
+ ArrayRef<MachineBasicBlock *> SRPoints) {
for (const auto &MBB : SRPoints) {
SmallString<16> Str;
yaml::SaveRestorePointEntry Entry;
diff --git a/llvm/tools/llvm-reduce/ReducerWorkItem.cpp b/llvm/tools/llvm-reduce/ReducerWorkItem.cpp
index 248714f284f08..b1138ef9d5289 100644
--- a/llvm/tools/llvm-reduce/ReducerWorkItem.cpp
+++ b/llvm/tools/llvm-reduce/ReducerWorkItem.cpp
@@ -62,6 +62,15 @@ static cl::opt<bool> TmpFilesAsBitcode(
cl::desc("Always write temporary files as bitcode instead of textual IR"),
cl::init(false), cl::cat(LLVMReduceOptions));
+static SmallVector<MachineBasicBlock *> constructSaveRestorePoints(
+ ArrayRef<MachineBasicBlock *> SRPoints,
+ const DenseMap<MachineBasicBlock *, MachineBasicBlock *> &BBMap) {
+ SmallVector<MachineBasicBlock *> Pts;
+ for (auto &Src : SRPoints)
+ Pts.push_back(BBMap.find(Src)->second);
+ return Pts;
+}
+
static void cloneFrameInfo(
MachineFrameInfo &DstMFI, const MachineFrameInfo &SrcMFI,
const DenseMap<MachineBasicBlock *, MachineBasicBlock *> &Src2DstMBB) {
@@ -95,14 +104,14 @@ static void cloneFrameInfo(
assert(SrcMFI.getSavePoints().size() < 2 &&
"Multiple restore points not yet supported!");
- DstMFI.setSavePoints(MachineFrameInfo::constructSaveRestorePoints(
- SrcMFI.getSavePoints(), Src2DstMBB));
+ DstMFI.setSavePoints(
+ constructSaveRestorePoints(SrcMFI.getSavePoints(), Src2DstMBB));
assert(SrcMFI.getRestorePoints().size() < 2 &&
"Multiple restore points not yet supported!");
- DstMFI.setRestorePoints(MachineFrameInfo::constructSaveRestorePoints(
- SrcMFI.getRestorePoints(), Src2DstMBB));
+ DstMFI.setRestorePoints(
+ constructSaveRestorePoints(SrcMFI.getRestorePoints(), Src2DstMBB));
auto CopyObjectProperties = [](MachineFrameInfo &DstMFI,
const MachineFrameInfo &SrcMFI, int FI) {
More information about the llvm-commits
mailing list