summaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MIRPrinter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/MIRPrinter.cpp')
-rw-r--r--llvm/lib/CodeGen/MIRPrinter.cpp39
1 files changed, 31 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp
index 91a21a4adf4e..bf8a6cdf097a 100644
--- a/llvm/lib/CodeGen/MIRPrinter.cpp
+++ b/llvm/lib/CodeGen/MIRPrinter.cpp
@@ -149,11 +149,13 @@ static void convertMCP(yaml::MachineFunction &MF,
static void convertMJTI(ModuleSlotTracker &MST, yaml::MachineJumpTable &YamlJTI,
const MachineJumpTableInfo &JTI);
static void convertMFI(ModuleSlotTracker &MST, yaml::MachineFrameInfo &YamlMFI,
- const MachineFrameInfo &MFI);
+ const MachineFrameInfo &MFI,
+ const TargetRegisterInfo *TRI);
static void
convertSRPoints(ModuleSlotTracker &MST,
std::vector<yaml::SaveRestorePointEntry> &YamlSRPoints,
- ArrayRef<MachineBasicBlock *> SaveRestorePoints);
+ const llvm::SaveRestorePoints &SRPoints,
+ const TargetRegisterInfo *TRI);
static void convertStackObjects(yaml::MachineFunction &YMF,
const MachineFunction &MF,
ModuleSlotTracker &MST, MFPrintState &State);
@@ -204,7 +206,8 @@ static void printMF(raw_ostream &OS, const MachineModuleInfo &MMI,
convertMRI(YamlMF, MF, MF.getRegInfo(), MF.getSubtarget().getRegisterInfo());
MachineModuleSlotTracker &MST = State.MST;
MST.incorporateFunction(MF.getFunction());
- convertMFI(MST, YamlMF.FrameInfo, MF.getFrameInfo());
+ convertMFI(MST, YamlMF.FrameInfo, MF.getFrameInfo(),
+ MF.getSubtarget().getRegisterInfo());
convertStackObjects(YamlMF, MF, MST, State);
convertEntryValueObjects(YamlMF, MF, MST);
convertCallSiteObjects(YamlMF, MF, MST);
@@ -339,7 +342,8 @@ static void convertMRI(yaml::MachineFunction &YamlMF, const MachineFunction &MF,
}
static void convertMFI(ModuleSlotTracker &MST, yaml::MachineFrameInfo &YamlMFI,
- const MachineFrameInfo &MFI) {
+ const MachineFrameInfo &MFI,
+ const TargetRegisterInfo *TRI) {
YamlMFI.IsFrameAddressTaken = MFI.isFrameAddressTaken();
YamlMFI.IsReturnAddressTaken = MFI.isReturnAddressTaken();
YamlMFI.HasStackMap = MFI.hasStackMap();
@@ -360,9 +364,9 @@ static void convertMFI(ModuleSlotTracker &MST, yaml::MachineFrameInfo &YamlMFI,
YamlMFI.IsCalleeSavedInfoValid = MFI.isCalleeSavedInfoValid();
YamlMFI.LocalFrameSize = MFI.getLocalFrameSize();
if (!MFI.getSavePoints().empty())
- convertSRPoints(MST, YamlMFI.SavePoints, MFI.getSavePoints());
+ convertSRPoints(MST, YamlMFI.SavePoints, MFI.getSavePoints(), TRI);
if (!MFI.getRestorePoints().empty())
- convertSRPoints(MST, YamlMFI.RestorePoints, MFI.getRestorePoints());
+ convertSRPoints(MST, YamlMFI.RestorePoints, MFI.getRestorePoints(), TRI);
}
static void convertEntryValueObjects(yaml::MachineFunction &YMF,
@@ -619,16 +623,35 @@ static void convertMCP(yaml::MachineFunction &MF,
static void
convertSRPoints(ModuleSlotTracker &MST,
std::vector<yaml::SaveRestorePointEntry> &YamlSRPoints,
- ArrayRef<MachineBasicBlock *> SRPoints) {
- for (const auto &MBB : SRPoints) {
+ const llvm::SaveRestorePoints &SRPoints,
+ const TargetRegisterInfo *TRI) {
+ for (const auto &[MBB, CSInfos] : SRPoints) {
SmallString<16> Str;
yaml::SaveRestorePointEntry Entry;
raw_svector_ostream StrOS(Str);
StrOS << printMBBReference(*MBB);
Entry.Point = StrOS.str().str();
Str.clear();
+ for (const CalleeSavedInfo &Info : CSInfos) {
+ if (Info.getReg()) {
+ StrOS << printReg(Info.getReg(), TRI);
+ Entry.Registers.push_back(StrOS.str().str());
+ Str.clear();
+ }
+ }
+ // Sort here needed for stable output for lit tests
+ std::sort(Entry.Registers.begin(), Entry.Registers.end(),
+ [](const yaml::StringValue &Lhs, const yaml::StringValue &Rhs) {
+ return Lhs.Value < Rhs.Value;
+ });
YamlSRPoints.push_back(std::move(Entry));
}
+ // Sort here needed for stable output for lit tests
+ std::sort(YamlSRPoints.begin(), YamlSRPoints.end(),
+ [](const yaml::SaveRestorePointEntry &Lhs,
+ const yaml::SaveRestorePointEntry &Rhs) {
+ return Lhs.Point.Value < Rhs.Point.Value;
+ });
}
static void convertMJTI(ModuleSlotTracker &MST, yaml::MachineJumpTable &YamlJTI,