-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
[llvm] Support multiple save/restore points in mir #119357
base: main
Are you sure you want to change the base?
[llvm] Support multiple save/restore points in mir #119357
Conversation
@llvm/pr-subscribers-backend-x86 @llvm/pr-subscribers-backend-webassembly Author: Elizaveta Noskova (enoskova-sc) ChangesCurrently mir supports only one save and one restore point specification:
This patch provide possibility to have multiple save and multiple restore points in mir:
Shrink-Wrap points split Part 3. Part 1: #117862 Patch is 276.31 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/119357.diff 340 Files Affected:
diff --git a/llvm/include/llvm/CodeGen/MIRYamlMapping.h b/llvm/include/llvm/CodeGen/MIRYamlMapping.h
index 09a6ca936fe1f4..be8a8e593ef922 100644
--- a/llvm/include/llvm/CodeGen/MIRYamlMapping.h
+++ b/llvm/include/llvm/CodeGen/MIRYamlMapping.h
@@ -610,6 +610,20 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineJumpTable::Entry)
namespace llvm {
namespace yaml {
+struct SRPEntry {
+ StringValue Point;
+
+ bool operator==(const SRPEntry &Other) const { return Point == Other.Point; }
+};
+
+using SaveRestorePoints = std::vector<SRPEntry>;
+
+template <> struct MappingTraits<SRPEntry> {
+ static void mapping(IO &YamlIO, SRPEntry &Entry) {
+ YamlIO.mapRequired("point", Entry.Point);
+ }
+};
+
template <> struct MappingTraits<MachineJumpTable> {
static void mapping(IO &YamlIO, MachineJumpTable &JT) {
YamlIO.mapRequired("kind", JT.Kind);
@@ -618,6 +632,14 @@ template <> struct MappingTraits<MachineJumpTable> {
}
};
+} // namespace yaml
+} // namespace llvm
+
+LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::SRPEntry)
+
+namespace llvm {
+namespace yaml {
+
/// Serializable representation of MachineFrameInfo.
///
/// Doesn't serialize attributes like 'StackAlignment', 'IsStackRealignable' and
@@ -645,8 +667,8 @@ struct MachineFrameInfo {
bool HasTailCall = false;
bool IsCalleeSavedInfoValid = false;
unsigned LocalFrameSize = 0;
- StringValue SavePoint;
- StringValue RestorePoint;
+ SaveRestorePoints SavePoints;
+ SaveRestorePoints RestorePoints;
bool operator==(const MachineFrameInfo &Other) const {
return IsFrameAddressTaken == Other.IsFrameAddressTaken &&
@@ -667,7 +689,8 @@ struct MachineFrameInfo {
HasMustTailInVarArgFunc == Other.HasMustTailInVarArgFunc &&
HasTailCall == Other.HasTailCall &&
LocalFrameSize == Other.LocalFrameSize &&
- SavePoint == Other.SavePoint && RestorePoint == Other.RestorePoint &&
+ SavePoints == Other.SavePoints &&
+ RestorePoints == Other.RestorePoints &&
IsCalleeSavedInfoValid == Other.IsCalleeSavedInfoValid;
}
};
@@ -699,10 +722,12 @@ template <> struct MappingTraits<MachineFrameInfo> {
YamlIO.mapOptional("isCalleeSavedInfoValid", MFI.IsCalleeSavedInfoValid,
false);
YamlIO.mapOptional("localFrameSize", MFI.LocalFrameSize, (unsigned)0);
- YamlIO.mapOptional("savePoint", MFI.SavePoint,
- StringValue()); // Don't print it out when it's empty.
- YamlIO.mapOptional("restorePoint", MFI.RestorePoint,
- StringValue()); // Don't print it out when it's empty.
+ YamlIO.mapOptional(
+ "savePoints", MFI.SavePoints,
+ SaveRestorePoints()); // Don't print it out when it's empty.
+ YamlIO.mapOptional(
+ "restorePoints", MFI.RestorePoints,
+ SaveRestorePoints()); // Don't print it out when it's empty.
}
};
diff --git a/llvm/include/llvm/CodeGen/MachineDominators.h b/llvm/include/llvm/CodeGen/MachineDominators.h
index 74cf94398736dd..88800d91ef51a9 100644
--- a/llvm/include/llvm/CodeGen/MachineDominators.h
+++ b/llvm/include/llvm/CodeGen/MachineDominators.h
@@ -185,6 +185,11 @@ class MachineDominatorTree : public DomTreeBase<MachineBasicBlock> {
return Base::findNearestCommonDominator(A, B);
}
+ /// Returns the nearest common dominator of the given blocks.
+ /// If that tree node is a virtual root, a nullptr will be returned.
+ MachineBasicBlock *
+ findNearestCommonDominator(ArrayRef<MachineBasicBlock *> Blocks) const;
+
MachineDomTreeNode *operator[](MachineBasicBlock *BB) const {
applySplitCriticalEdges();
return Base::getNode(BB);
diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
index e2543f883f91ce..f7c1e162d2a96e 100644
--- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
@@ -124,6 +124,10 @@ class MIRParserImpl {
bool initializeFrameInfo(PerFunctionMIParsingState &PFS,
const yaml::MachineFunction &YamlMF);
+ bool initializeSaveRestorePoints(PerFunctionMIParsingState &PFS,
+ const yaml::SaveRestorePoints &YamlSRP,
+ bool IsSavePoints);
+
bool initializeCallSiteInfo(PerFunctionMIParsingState &PFS,
const yaml::MachineFunction &YamlMF);
@@ -832,18 +836,9 @@ bool MIRParserImpl::initializeFrameInfo(PerFunctionMIParsingState &PFS,
MFI.setHasTailCall(YamlMFI.HasTailCall);
MFI.setCalleeSavedInfoValid(YamlMFI.IsCalleeSavedInfoValid);
MFI.setLocalFrameSize(YamlMFI.LocalFrameSize);
- if (!YamlMFI.SavePoint.Value.empty()) {
- MachineBasicBlock *MBB = nullptr;
- if (parseMBBReference(PFS, MBB, YamlMFI.SavePoint))
- return true;
- MFI.setSavePoint(MBB);
- }
- if (!YamlMFI.RestorePoint.Value.empty()) {
- MachineBasicBlock *MBB = nullptr;
- if (parseMBBReference(PFS, MBB, YamlMFI.RestorePoint))
- return true;
- MFI.setRestorePoint(MBB);
- }
+ initializeSaveRestorePoints(PFS, YamlMFI.SavePoints, true /*IsSavePoints*/);
+ initializeSaveRestorePoints(PFS, YamlMFI.RestorePoints,
+ false /*IsSavePoints*/);
std::vector<CalleeSavedInfo> CSIInfo;
// Initialize the fixed frame objects.
@@ -1058,8 +1053,28 @@ bool MIRParserImpl::initializeConstantPool(PerFunctionMIParsingState &PFS,
return false;
}
-bool MIRParserImpl::initializeJumpTableInfo(PerFunctionMIParsingState &PFS,
- const yaml::MachineJumpTable &YamlJTI) {
+bool MIRParserImpl::initializeSaveRestorePoints(
+ PerFunctionMIParsingState &PFS, const yaml::SaveRestorePoints &YamlSRP,
+ bool IsSavePoints) {
+ MachineFunction &MF = PFS.MF;
+ MachineFrameInfo &MFI = MF.getFrameInfo();
+
+ if (!YamlSRP.empty()) {
+ const auto &Entry = YamlSRP.front();
+ const auto &MBBSource = Entry.Point;
+ MachineBasicBlock *MBB = nullptr;
+ if (parseMBBReference(PFS, MBB, MBBSource.Value))
+ return true;
+ if (IsSavePoints)
+ MFI.setSavePoint(MBB);
+ else
+ MFI.setRestorePoint(MBB);
+ }
+ return false;
+}
+
+bool MIRParserImpl::initializeJumpTableInfo(
+ PerFunctionMIParsingState &PFS, const yaml::MachineJumpTable &YamlJTI) {
MachineJumpTableInfo *JTI = PFS.MF.getOrCreateJumpTableInfo(YamlJTI.Kind);
for (const auto &Entry : YamlJTI.Entries) {
std::vector<MachineBasicBlock *> Blocks;
diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp
index c8f6341c1224d2..2d0728a6452808 100644
--- a/llvm/lib/CodeGen/MIRPrinter.cpp
+++ b/llvm/lib/CodeGen/MIRPrinter.cpp
@@ -118,6 +118,8 @@ class MIRPrinter {
const TargetRegisterInfo *TRI);
void convert(ModuleSlotTracker &MST, yaml::MachineFrameInfo &YamlMFI,
const MachineFrameInfo &MFI);
+ void convert(ModuleSlotTracker &MST, yaml::SaveRestorePoints &YamlSRP,
+ MachineBasicBlock *SaveRestorePoint);
void convert(yaml::MachineFunction &MF,
const MachineConstantPool &ConstantPool);
void convert(ModuleSlotTracker &MST, yaml::MachineJumpTable &YamlJTI,
@@ -392,14 +394,10 @@ void MIRPrinter::convert(ModuleSlotTracker &MST,
YamlMFI.HasTailCall = MFI.hasTailCall();
YamlMFI.IsCalleeSavedInfoValid = MFI.isCalleeSavedInfoValid();
YamlMFI.LocalFrameSize = MFI.getLocalFrameSize();
- if (MFI.getSavePoint()) {
- raw_string_ostream StrOS(YamlMFI.SavePoint.Value);
- StrOS << printMBBReference(*MFI.getSavePoint());
- }
- if (MFI.getRestorePoint()) {
- raw_string_ostream StrOS(YamlMFI.RestorePoint.Value);
- StrOS << printMBBReference(*MFI.getRestorePoint());
- }
+ if (MFI.getSavePoint())
+ convert(MST, YamlMFI.SavePoints, MFI.getSavePoint());
+ if (MFI.getRestorePoint())
+ convert(MST, YamlMFI.RestorePoints, MFI.getRestorePoint());
}
void MIRPrinter::convertEntryValueObjects(yaml::MachineFunction &YMF,
@@ -618,6 +616,18 @@ void MIRPrinter::convert(yaml::MachineFunction &MF,
}
}
+void MIRPrinter::convert(ModuleSlotTracker &MST,
+ yaml::SaveRestorePoints &YamlSRP,
+ MachineBasicBlock *SRP) {
+ std::string Str;
+ yaml::SRPEntry Entry;
+ raw_string_ostream StrOS(Str);
+ StrOS << printMBBReference(*SRP);
+ Entry.Point = StrOS.str();
+ Str.clear();
+ YamlSRP.push_back(Entry);
+}
+
void MIRPrinter::convert(ModuleSlotTracker &MST,
yaml::MachineJumpTable &YamlJTI,
const MachineJumpTableInfo &JTI) {
diff --git a/llvm/lib/CodeGen/MachineDominators.cpp b/llvm/lib/CodeGen/MachineDominators.cpp
index a2cc8fdfa7c9f9..384f90c6da66c0 100644
--- a/llvm/lib/CodeGen/MachineDominators.cpp
+++ b/llvm/lib/CodeGen/MachineDominators.cpp
@@ -189,3 +189,19 @@ void MachineDominatorTree::applySplitCriticalEdges() const {
NewBBs.clear();
CriticalEdgesToSplit.clear();
}
+
+MachineBasicBlock *MachineDominatorTree::findNearestCommonDominator(
+ ArrayRef<MachineBasicBlock *> Blocks) const {
+ assert(!Blocks.empty());
+
+ MachineBasicBlock *NCD = Blocks.front();
+ for (MachineBasicBlock *BB : Blocks.drop_front()) {
+ NCD = Base::findNearestCommonDominator(NCD, BB);
+
+ // Stop when the root is reached.
+ if (Base::isVirtualRoot(Base::getNode(NCD)))
+ return nullptr;
+ }
+
+ return NCD;
+}
diff --git a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
index deb0b627225c64..0de1f1d821a6e2 100644
--- a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
@@ -1607,6 +1607,8 @@ bool RISCVFrameLowering::assignCalleeSavedSpillSlots(
int FrameIdx = MFI.CreateFixedSpillStackObject(Size, Offset);
assert(FrameIdx < 0);
CS.setFrameIdx(FrameIdx);
+ if (RISCVRegisterInfo::isRVVRegClass(RC))
+ MFI.setStackID(FrameIdx, TargetStackID::ScalableVector);
continue;
}
}
@@ -1623,6 +1625,8 @@ bool RISCVFrameLowering::assignCalleeSavedSpillSlots(
if ((unsigned)FrameIdx > MaxCSFrameIndex)
MaxCSFrameIndex = FrameIdx;
CS.setFrameIdx(FrameIdx);
+ if (RISCVRegisterInfo::isRVVRegClass(RC))
+ MFI.setStackID(FrameIdx, TargetStackID::ScalableVector);
}
// Allocate a fixed object that covers the full push or libcall size.
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/store-merging-debug.mir b/llvm/test/CodeGen/AArch64/GlobalISel/store-merging-debug.mir
index d52ef0f3da74c7..2e8f3c460b2fe7 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/store-merging-debug.mir
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/store-merging-debug.mir
@@ -86,8 +86,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack: []
callSites: []
diff --git a/llvm/test/CodeGen/AArch64/aarch64-ldst-no-premature-sp-pop.mir b/llvm/test/CodeGen/AArch64/aarch64-ldst-no-premature-sp-pop.mir
index ba621cf77f9aed..07e80538e793f5 100644
--- a/llvm/test/CodeGen/AArch64/aarch64-ldst-no-premature-sp-pop.mir
+++ b/llvm/test/CodeGen/AArch64/aarch64-ldst-no-premature-sp-pop.mir
@@ -59,8 +59,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 16
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, type: default, offset: -16, size: 16,
diff --git a/llvm/test/CodeGen/AArch64/aarch64-mov-debug-locs.mir b/llvm/test/CodeGen/AArch64/aarch64-mov-debug-locs.mir
index 16e2de751381ad..31589a86599ff3 100644
--- a/llvm/test/CodeGen/AArch64/aarch64-mov-debug-locs.mir
+++ b/llvm/test/CodeGen/AArch64/aarch64-mov-debug-locs.mir
@@ -157,8 +157,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8,
diff --git a/llvm/test/CodeGen/AArch64/aarch64st1.mir b/llvm/test/CodeGen/AArch64/aarch64st1.mir
index 22a024d37bc64f..439db1e97aa794 100644
--- a/llvm/test/CodeGen/AArch64/aarch64st1.mir
+++ b/llvm/test/CodeGen/AArch64/aarch64st1.mir
@@ -58,8 +58,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: default, offset: 0, size: 4, alignment: 4,
diff --git a/llvm/test/CodeGen/AArch64/cfi-fixup-multi-block-prologue.mir b/llvm/test/CodeGen/AArch64/cfi-fixup-multi-block-prologue.mir
index 31fa3832367bec..6851fdba1239a4 100644
--- a/llvm/test/CodeGen/AArch64/cfi-fixup-multi-block-prologue.mir
+++ b/llvm/test/CodeGen/AArch64/cfi-fixup-multi-block-prologue.mir
@@ -80,8 +80,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 30000
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: p, type: default, offset: -30016, size: 30000, alignment: 1,
diff --git a/llvm/test/CodeGen/AArch64/cfi-fixup-multi-section.mir b/llvm/test/CodeGen/AArch64/cfi-fixup-multi-section.mir
index a24972d1388320..fe5c90a5e6dc54 100644
--- a/llvm/test/CodeGen/AArch64/cfi-fixup-multi-section.mir
+++ b/llvm/test/CodeGen/AArch64/cfi-fixup-multi-section.mir
@@ -47,8 +47,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: spill-slot, offset: -16, size: 8, alignment: 16,
diff --git a/llvm/test/CodeGen/AArch64/cfi-fixup.mir b/llvm/test/CodeGen/AArch64/cfi-fixup.mir
index f522df6bb3fa06..dd75cec7f6e0be 100644
--- a/llvm/test/CodeGen/AArch64/cfi-fixup.mir
+++ b/llvm/test/CodeGen/AArch64/cfi-fixup.mir
@@ -65,8 +65,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: spill-slot, offset: -16, size: 8, alignment: 16,
@@ -248,8 +248,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: spill-slot, offset: -16, size: 8, alignment: 16,
@@ -403,8 +403,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: spill-slot, offset: -16, size: 8, alignment: 16,
diff --git a/llvm/test/CodeGen/AArch64/dont-shrink-wrap-stack-mayloadorstore.mir b/llvm/test/CodeGen/AArch64/dont-shrink-wrap-stack-mayloadorstore.mir
index 1c4447bffd8729..85f8abcbf7fe60 100644
--- a/llvm/test/CodeGen/AArch64/dont-shrink-wrap-stack-mayloadorstore.mir
+++ b/llvm/test/CodeGen/AArch64/dont-shrink-wrap-stack-mayloadorstore.mir
@@ -6,17 +6,23 @@
; RUN: llc -x=mir -simplify-mir -run-pass=shrink-wrap -o - %s | FileCheck %s
; CHECK: name: compiler_pop_stack
; CHECK: frameInfo:
- ; CHECK: savePoint: '%bb.1'
- ; CHECK: restorePoint: '%bb.7'
+ ; CHECK: savePoints:
+ ; CHECK-NEXT: - point: '%bb.1'
+ ; CHECK: restorePoints:
+ ; CHECK-NEXT: - point: '%bb.7'
; CHECK: name: compiler_pop_stack_no_memoperands
; CHECK: frameInfo:
- ; CHECK: savePoint: '%bb.1'
- ; CHECK: restorePoint: '%bb.7'
+ ; CHECK: savePoints:
+ ; CHECK-NEXT: - point: '%bb.1'
+ ; CHECK: restorePoints:
+ ; CHECK-NEXT: - point: '%bb.7'
; CHECK: name: f
; CHECK: frameInfo:
- ; CHECK: savePoint: '%bb.2'
- ; CHECK-NEXT: restorePoint: '%bb.4'
- ; CHECK-NEXT: stack:
+ ; CHECK: savePoints:
+ ; CHECK-NEXT: - point: '%bb.2'
+ ; CHECK: restorePoints:
+ ; CHECK-NEXT: - point: '%bb.4'
+ ; CHECK: stack:
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64"
diff --git a/llvm/test/CodeGen/AArch64/early-ifcvt-regclass-mismatch.mir b/llvm/test/CodeGen/AArch64/early-ifcvt-regclass-mismatch.mir
index a7f67f8b682c3c..6324db0cb2c0ff 100644
--- a/llvm/test/CodeGen/AArch64/early-ifcvt-regclass-mismatch.mir
+++ b/llvm/test/CodeGen/AArch64/early-ifcvt-regclass-mismatch.mir
@@ -105,8 +105,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack: []
callSites: []
diff --git a/llvm/test/CodeGen/AArch64/emit_fneg_with_non_register_operand.mir b/llvm/test/CodeGen/AArch64/emit_fneg_with_non_register_operand.mir
index f9878adfe5e448..3c98a1a128413e 100644
--- a/llvm/test/CodeGen/AArch64/emit_fneg_with_non_register_operand.mir
+++ b/llvm/test/CodeGen/AArch64/emit_fneg_with_non_register_operand.mir
@@ -75,8 +75,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: true
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack: []
entry_values: []
diff --git a/llvm/test/CodeGen/AArch64/irg-nomem.mir b/llvm/test/CodeGen/AArch64/irg-nomem.mir
index 3b000fafbed46f..78438151405e66 100644
--- a/llvm/test/CodeGen/AArch64/irg-nomem.mir
+++ b/llvm/test/CodeGen/AArch64/irg-nomem.mir
@@ -47,8 +47,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack: []
callSites: []
diff --git a/llvm/test/CodeGen/AArch64/jump-table-duplicate.mir b/llvm/test/CodeGen/AArch64/jump-table-duplicate.mir
index a2532a854923f5..81cf5953895cab 100644
--- a/llvm/test/CodeGen/AArch64/jump-table-duplicate.mir
+++ b/llvm/test/CodeGen/AArch64/jump-table-duplicate.mir
@@ -92,8 +92,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8,
diff --git a/llvm/test/CodeGen/AArch64/ldst-nopreidx-sp-redzone.mir b/llvm/test/CodeGen/AArch64/ldst-nopreidx-sp-redzone.mir
index f1f9e5fbc9b087..b431de2d9b35b3 100644
--- a/llvm/test/CodeGen/AArch64/ldst-nopreidx-sp-redzone.mir
+++ b/llvm/test/CodeGen/AArch64/ldst-nopreidx-sp-redzone.mir
@@ -103,8 +103,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 480
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: StackGuardSlot, type: default, offset: -40, size: 8,
@@ -216,8 +216,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 480
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: StackGuardSlot, type: default, offset: -40, size: 8,
@@ -327,8 +327,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 480
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: StackGuardSlot, type: default, offset: -40, size: 8,
diff --git a/llvm/test/CodeGen/AArch64/live-debugvalues-sve.mir b/llvm/test/CodeGen/AArch64/live-debugvalues-sve.mir
index 612453ab53f438..4be16228814a3b 100644
--- a/llvm/test/CodeGen/AArch64/live-debugvalues-sve.mir
+++ b/llvm/test/CodeGen/AArch64/live-debugvalues-sve.mir
@@ -120,8 +120,10 @@ frameInfo:
adjustsStack: true
hasC...
[truncated]
|
@llvm/pr-subscribers-backend-aarch64 Author: Elizaveta Noskova (enoskova-sc) ChangesCurrently mir supports only one save and one restore point specification:
This patch provide possibility to have multiple save and multiple restore points in mir:
Shrink-Wrap points split Part 3. Part 1: #117862 Patch is 276.31 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/119357.diff 340 Files Affected:
diff --git a/llvm/include/llvm/CodeGen/MIRYamlMapping.h b/llvm/include/llvm/CodeGen/MIRYamlMapping.h
index 09a6ca936fe1f4..be8a8e593ef922 100644
--- a/llvm/include/llvm/CodeGen/MIRYamlMapping.h
+++ b/llvm/include/llvm/CodeGen/MIRYamlMapping.h
@@ -610,6 +610,20 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineJumpTable::Entry)
namespace llvm {
namespace yaml {
+struct SRPEntry {
+ StringValue Point;
+
+ bool operator==(const SRPEntry &Other) const { return Point == Other.Point; }
+};
+
+using SaveRestorePoints = std::vector<SRPEntry>;
+
+template <> struct MappingTraits<SRPEntry> {
+ static void mapping(IO &YamlIO, SRPEntry &Entry) {
+ YamlIO.mapRequired("point", Entry.Point);
+ }
+};
+
template <> struct MappingTraits<MachineJumpTable> {
static void mapping(IO &YamlIO, MachineJumpTable &JT) {
YamlIO.mapRequired("kind", JT.Kind);
@@ -618,6 +632,14 @@ template <> struct MappingTraits<MachineJumpTable> {
}
};
+} // namespace yaml
+} // namespace llvm
+
+LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::SRPEntry)
+
+namespace llvm {
+namespace yaml {
+
/// Serializable representation of MachineFrameInfo.
///
/// Doesn't serialize attributes like 'StackAlignment', 'IsStackRealignable' and
@@ -645,8 +667,8 @@ struct MachineFrameInfo {
bool HasTailCall = false;
bool IsCalleeSavedInfoValid = false;
unsigned LocalFrameSize = 0;
- StringValue SavePoint;
- StringValue RestorePoint;
+ SaveRestorePoints SavePoints;
+ SaveRestorePoints RestorePoints;
bool operator==(const MachineFrameInfo &Other) const {
return IsFrameAddressTaken == Other.IsFrameAddressTaken &&
@@ -667,7 +689,8 @@ struct MachineFrameInfo {
HasMustTailInVarArgFunc == Other.HasMustTailInVarArgFunc &&
HasTailCall == Other.HasTailCall &&
LocalFrameSize == Other.LocalFrameSize &&
- SavePoint == Other.SavePoint && RestorePoint == Other.RestorePoint &&
+ SavePoints == Other.SavePoints &&
+ RestorePoints == Other.RestorePoints &&
IsCalleeSavedInfoValid == Other.IsCalleeSavedInfoValid;
}
};
@@ -699,10 +722,12 @@ template <> struct MappingTraits<MachineFrameInfo> {
YamlIO.mapOptional("isCalleeSavedInfoValid", MFI.IsCalleeSavedInfoValid,
false);
YamlIO.mapOptional("localFrameSize", MFI.LocalFrameSize, (unsigned)0);
- YamlIO.mapOptional("savePoint", MFI.SavePoint,
- StringValue()); // Don't print it out when it's empty.
- YamlIO.mapOptional("restorePoint", MFI.RestorePoint,
- StringValue()); // Don't print it out when it's empty.
+ YamlIO.mapOptional(
+ "savePoints", MFI.SavePoints,
+ SaveRestorePoints()); // Don't print it out when it's empty.
+ YamlIO.mapOptional(
+ "restorePoints", MFI.RestorePoints,
+ SaveRestorePoints()); // Don't print it out when it's empty.
}
};
diff --git a/llvm/include/llvm/CodeGen/MachineDominators.h b/llvm/include/llvm/CodeGen/MachineDominators.h
index 74cf94398736dd..88800d91ef51a9 100644
--- a/llvm/include/llvm/CodeGen/MachineDominators.h
+++ b/llvm/include/llvm/CodeGen/MachineDominators.h
@@ -185,6 +185,11 @@ class MachineDominatorTree : public DomTreeBase<MachineBasicBlock> {
return Base::findNearestCommonDominator(A, B);
}
+ /// Returns the nearest common dominator of the given blocks.
+ /// If that tree node is a virtual root, a nullptr will be returned.
+ MachineBasicBlock *
+ findNearestCommonDominator(ArrayRef<MachineBasicBlock *> Blocks) const;
+
MachineDomTreeNode *operator[](MachineBasicBlock *BB) const {
applySplitCriticalEdges();
return Base::getNode(BB);
diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
index e2543f883f91ce..f7c1e162d2a96e 100644
--- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
@@ -124,6 +124,10 @@ class MIRParserImpl {
bool initializeFrameInfo(PerFunctionMIParsingState &PFS,
const yaml::MachineFunction &YamlMF);
+ bool initializeSaveRestorePoints(PerFunctionMIParsingState &PFS,
+ const yaml::SaveRestorePoints &YamlSRP,
+ bool IsSavePoints);
+
bool initializeCallSiteInfo(PerFunctionMIParsingState &PFS,
const yaml::MachineFunction &YamlMF);
@@ -832,18 +836,9 @@ bool MIRParserImpl::initializeFrameInfo(PerFunctionMIParsingState &PFS,
MFI.setHasTailCall(YamlMFI.HasTailCall);
MFI.setCalleeSavedInfoValid(YamlMFI.IsCalleeSavedInfoValid);
MFI.setLocalFrameSize(YamlMFI.LocalFrameSize);
- if (!YamlMFI.SavePoint.Value.empty()) {
- MachineBasicBlock *MBB = nullptr;
- if (parseMBBReference(PFS, MBB, YamlMFI.SavePoint))
- return true;
- MFI.setSavePoint(MBB);
- }
- if (!YamlMFI.RestorePoint.Value.empty()) {
- MachineBasicBlock *MBB = nullptr;
- if (parseMBBReference(PFS, MBB, YamlMFI.RestorePoint))
- return true;
- MFI.setRestorePoint(MBB);
- }
+ initializeSaveRestorePoints(PFS, YamlMFI.SavePoints, true /*IsSavePoints*/);
+ initializeSaveRestorePoints(PFS, YamlMFI.RestorePoints,
+ false /*IsSavePoints*/);
std::vector<CalleeSavedInfo> CSIInfo;
// Initialize the fixed frame objects.
@@ -1058,8 +1053,28 @@ bool MIRParserImpl::initializeConstantPool(PerFunctionMIParsingState &PFS,
return false;
}
-bool MIRParserImpl::initializeJumpTableInfo(PerFunctionMIParsingState &PFS,
- const yaml::MachineJumpTable &YamlJTI) {
+bool MIRParserImpl::initializeSaveRestorePoints(
+ PerFunctionMIParsingState &PFS, const yaml::SaveRestorePoints &YamlSRP,
+ bool IsSavePoints) {
+ MachineFunction &MF = PFS.MF;
+ MachineFrameInfo &MFI = MF.getFrameInfo();
+
+ if (!YamlSRP.empty()) {
+ const auto &Entry = YamlSRP.front();
+ const auto &MBBSource = Entry.Point;
+ MachineBasicBlock *MBB = nullptr;
+ if (parseMBBReference(PFS, MBB, MBBSource.Value))
+ return true;
+ if (IsSavePoints)
+ MFI.setSavePoint(MBB);
+ else
+ MFI.setRestorePoint(MBB);
+ }
+ return false;
+}
+
+bool MIRParserImpl::initializeJumpTableInfo(
+ PerFunctionMIParsingState &PFS, const yaml::MachineJumpTable &YamlJTI) {
MachineJumpTableInfo *JTI = PFS.MF.getOrCreateJumpTableInfo(YamlJTI.Kind);
for (const auto &Entry : YamlJTI.Entries) {
std::vector<MachineBasicBlock *> Blocks;
diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp
index c8f6341c1224d2..2d0728a6452808 100644
--- a/llvm/lib/CodeGen/MIRPrinter.cpp
+++ b/llvm/lib/CodeGen/MIRPrinter.cpp
@@ -118,6 +118,8 @@ class MIRPrinter {
const TargetRegisterInfo *TRI);
void convert(ModuleSlotTracker &MST, yaml::MachineFrameInfo &YamlMFI,
const MachineFrameInfo &MFI);
+ void convert(ModuleSlotTracker &MST, yaml::SaveRestorePoints &YamlSRP,
+ MachineBasicBlock *SaveRestorePoint);
void convert(yaml::MachineFunction &MF,
const MachineConstantPool &ConstantPool);
void convert(ModuleSlotTracker &MST, yaml::MachineJumpTable &YamlJTI,
@@ -392,14 +394,10 @@ void MIRPrinter::convert(ModuleSlotTracker &MST,
YamlMFI.HasTailCall = MFI.hasTailCall();
YamlMFI.IsCalleeSavedInfoValid = MFI.isCalleeSavedInfoValid();
YamlMFI.LocalFrameSize = MFI.getLocalFrameSize();
- if (MFI.getSavePoint()) {
- raw_string_ostream StrOS(YamlMFI.SavePoint.Value);
- StrOS << printMBBReference(*MFI.getSavePoint());
- }
- if (MFI.getRestorePoint()) {
- raw_string_ostream StrOS(YamlMFI.RestorePoint.Value);
- StrOS << printMBBReference(*MFI.getRestorePoint());
- }
+ if (MFI.getSavePoint())
+ convert(MST, YamlMFI.SavePoints, MFI.getSavePoint());
+ if (MFI.getRestorePoint())
+ convert(MST, YamlMFI.RestorePoints, MFI.getRestorePoint());
}
void MIRPrinter::convertEntryValueObjects(yaml::MachineFunction &YMF,
@@ -618,6 +616,18 @@ void MIRPrinter::convert(yaml::MachineFunction &MF,
}
}
+void MIRPrinter::convert(ModuleSlotTracker &MST,
+ yaml::SaveRestorePoints &YamlSRP,
+ MachineBasicBlock *SRP) {
+ std::string Str;
+ yaml::SRPEntry Entry;
+ raw_string_ostream StrOS(Str);
+ StrOS << printMBBReference(*SRP);
+ Entry.Point = StrOS.str();
+ Str.clear();
+ YamlSRP.push_back(Entry);
+}
+
void MIRPrinter::convert(ModuleSlotTracker &MST,
yaml::MachineJumpTable &YamlJTI,
const MachineJumpTableInfo &JTI) {
diff --git a/llvm/lib/CodeGen/MachineDominators.cpp b/llvm/lib/CodeGen/MachineDominators.cpp
index a2cc8fdfa7c9f9..384f90c6da66c0 100644
--- a/llvm/lib/CodeGen/MachineDominators.cpp
+++ b/llvm/lib/CodeGen/MachineDominators.cpp
@@ -189,3 +189,19 @@ void MachineDominatorTree::applySplitCriticalEdges() const {
NewBBs.clear();
CriticalEdgesToSplit.clear();
}
+
+MachineBasicBlock *MachineDominatorTree::findNearestCommonDominator(
+ ArrayRef<MachineBasicBlock *> Blocks) const {
+ assert(!Blocks.empty());
+
+ MachineBasicBlock *NCD = Blocks.front();
+ for (MachineBasicBlock *BB : Blocks.drop_front()) {
+ NCD = Base::findNearestCommonDominator(NCD, BB);
+
+ // Stop when the root is reached.
+ if (Base::isVirtualRoot(Base::getNode(NCD)))
+ return nullptr;
+ }
+
+ return NCD;
+}
diff --git a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
index deb0b627225c64..0de1f1d821a6e2 100644
--- a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
@@ -1607,6 +1607,8 @@ bool RISCVFrameLowering::assignCalleeSavedSpillSlots(
int FrameIdx = MFI.CreateFixedSpillStackObject(Size, Offset);
assert(FrameIdx < 0);
CS.setFrameIdx(FrameIdx);
+ if (RISCVRegisterInfo::isRVVRegClass(RC))
+ MFI.setStackID(FrameIdx, TargetStackID::ScalableVector);
continue;
}
}
@@ -1623,6 +1625,8 @@ bool RISCVFrameLowering::assignCalleeSavedSpillSlots(
if ((unsigned)FrameIdx > MaxCSFrameIndex)
MaxCSFrameIndex = FrameIdx;
CS.setFrameIdx(FrameIdx);
+ if (RISCVRegisterInfo::isRVVRegClass(RC))
+ MFI.setStackID(FrameIdx, TargetStackID::ScalableVector);
}
// Allocate a fixed object that covers the full push or libcall size.
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/store-merging-debug.mir b/llvm/test/CodeGen/AArch64/GlobalISel/store-merging-debug.mir
index d52ef0f3da74c7..2e8f3c460b2fe7 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/store-merging-debug.mir
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/store-merging-debug.mir
@@ -86,8 +86,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack: []
callSites: []
diff --git a/llvm/test/CodeGen/AArch64/aarch64-ldst-no-premature-sp-pop.mir b/llvm/test/CodeGen/AArch64/aarch64-ldst-no-premature-sp-pop.mir
index ba621cf77f9aed..07e80538e793f5 100644
--- a/llvm/test/CodeGen/AArch64/aarch64-ldst-no-premature-sp-pop.mir
+++ b/llvm/test/CodeGen/AArch64/aarch64-ldst-no-premature-sp-pop.mir
@@ -59,8 +59,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 16
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, type: default, offset: -16, size: 16,
diff --git a/llvm/test/CodeGen/AArch64/aarch64-mov-debug-locs.mir b/llvm/test/CodeGen/AArch64/aarch64-mov-debug-locs.mir
index 16e2de751381ad..31589a86599ff3 100644
--- a/llvm/test/CodeGen/AArch64/aarch64-mov-debug-locs.mir
+++ b/llvm/test/CodeGen/AArch64/aarch64-mov-debug-locs.mir
@@ -157,8 +157,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8,
diff --git a/llvm/test/CodeGen/AArch64/aarch64st1.mir b/llvm/test/CodeGen/AArch64/aarch64st1.mir
index 22a024d37bc64f..439db1e97aa794 100644
--- a/llvm/test/CodeGen/AArch64/aarch64st1.mir
+++ b/llvm/test/CodeGen/AArch64/aarch64st1.mir
@@ -58,8 +58,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: default, offset: 0, size: 4, alignment: 4,
diff --git a/llvm/test/CodeGen/AArch64/cfi-fixup-multi-block-prologue.mir b/llvm/test/CodeGen/AArch64/cfi-fixup-multi-block-prologue.mir
index 31fa3832367bec..6851fdba1239a4 100644
--- a/llvm/test/CodeGen/AArch64/cfi-fixup-multi-block-prologue.mir
+++ b/llvm/test/CodeGen/AArch64/cfi-fixup-multi-block-prologue.mir
@@ -80,8 +80,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 30000
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: p, type: default, offset: -30016, size: 30000, alignment: 1,
diff --git a/llvm/test/CodeGen/AArch64/cfi-fixup-multi-section.mir b/llvm/test/CodeGen/AArch64/cfi-fixup-multi-section.mir
index a24972d1388320..fe5c90a5e6dc54 100644
--- a/llvm/test/CodeGen/AArch64/cfi-fixup-multi-section.mir
+++ b/llvm/test/CodeGen/AArch64/cfi-fixup-multi-section.mir
@@ -47,8 +47,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: spill-slot, offset: -16, size: 8, alignment: 16,
diff --git a/llvm/test/CodeGen/AArch64/cfi-fixup.mir b/llvm/test/CodeGen/AArch64/cfi-fixup.mir
index f522df6bb3fa06..dd75cec7f6e0be 100644
--- a/llvm/test/CodeGen/AArch64/cfi-fixup.mir
+++ b/llvm/test/CodeGen/AArch64/cfi-fixup.mir
@@ -65,8 +65,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: spill-slot, offset: -16, size: 8, alignment: 16,
@@ -248,8 +248,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: spill-slot, offset: -16, size: 8, alignment: 16,
@@ -403,8 +403,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: spill-slot, offset: -16, size: 8, alignment: 16,
diff --git a/llvm/test/CodeGen/AArch64/dont-shrink-wrap-stack-mayloadorstore.mir b/llvm/test/CodeGen/AArch64/dont-shrink-wrap-stack-mayloadorstore.mir
index 1c4447bffd8729..85f8abcbf7fe60 100644
--- a/llvm/test/CodeGen/AArch64/dont-shrink-wrap-stack-mayloadorstore.mir
+++ b/llvm/test/CodeGen/AArch64/dont-shrink-wrap-stack-mayloadorstore.mir
@@ -6,17 +6,23 @@
; RUN: llc -x=mir -simplify-mir -run-pass=shrink-wrap -o - %s | FileCheck %s
; CHECK: name: compiler_pop_stack
; CHECK: frameInfo:
- ; CHECK: savePoint: '%bb.1'
- ; CHECK: restorePoint: '%bb.7'
+ ; CHECK: savePoints:
+ ; CHECK-NEXT: - point: '%bb.1'
+ ; CHECK: restorePoints:
+ ; CHECK-NEXT: - point: '%bb.7'
; CHECK: name: compiler_pop_stack_no_memoperands
; CHECK: frameInfo:
- ; CHECK: savePoint: '%bb.1'
- ; CHECK: restorePoint: '%bb.7'
+ ; CHECK: savePoints:
+ ; CHECK-NEXT: - point: '%bb.1'
+ ; CHECK: restorePoints:
+ ; CHECK-NEXT: - point: '%bb.7'
; CHECK: name: f
; CHECK: frameInfo:
- ; CHECK: savePoint: '%bb.2'
- ; CHECK-NEXT: restorePoint: '%bb.4'
- ; CHECK-NEXT: stack:
+ ; CHECK: savePoints:
+ ; CHECK-NEXT: - point: '%bb.2'
+ ; CHECK: restorePoints:
+ ; CHECK-NEXT: - point: '%bb.4'
+ ; CHECK: stack:
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64"
diff --git a/llvm/test/CodeGen/AArch64/early-ifcvt-regclass-mismatch.mir b/llvm/test/CodeGen/AArch64/early-ifcvt-regclass-mismatch.mir
index a7f67f8b682c3c..6324db0cb2c0ff 100644
--- a/llvm/test/CodeGen/AArch64/early-ifcvt-regclass-mismatch.mir
+++ b/llvm/test/CodeGen/AArch64/early-ifcvt-regclass-mismatch.mir
@@ -105,8 +105,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack: []
callSites: []
diff --git a/llvm/test/CodeGen/AArch64/emit_fneg_with_non_register_operand.mir b/llvm/test/CodeGen/AArch64/emit_fneg_with_non_register_operand.mir
index f9878adfe5e448..3c98a1a128413e 100644
--- a/llvm/test/CodeGen/AArch64/emit_fneg_with_non_register_operand.mir
+++ b/llvm/test/CodeGen/AArch64/emit_fneg_with_non_register_operand.mir
@@ -75,8 +75,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: true
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack: []
entry_values: []
diff --git a/llvm/test/CodeGen/AArch64/irg-nomem.mir b/llvm/test/CodeGen/AArch64/irg-nomem.mir
index 3b000fafbed46f..78438151405e66 100644
--- a/llvm/test/CodeGen/AArch64/irg-nomem.mir
+++ b/llvm/test/CodeGen/AArch64/irg-nomem.mir
@@ -47,8 +47,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack: []
callSites: []
diff --git a/llvm/test/CodeGen/AArch64/jump-table-duplicate.mir b/llvm/test/CodeGen/AArch64/jump-table-duplicate.mir
index a2532a854923f5..81cf5953895cab 100644
--- a/llvm/test/CodeGen/AArch64/jump-table-duplicate.mir
+++ b/llvm/test/CodeGen/AArch64/jump-table-duplicate.mir
@@ -92,8 +92,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8,
diff --git a/llvm/test/CodeGen/AArch64/ldst-nopreidx-sp-redzone.mir b/llvm/test/CodeGen/AArch64/ldst-nopreidx-sp-redzone.mir
index f1f9e5fbc9b087..b431de2d9b35b3 100644
--- a/llvm/test/CodeGen/AArch64/ldst-nopreidx-sp-redzone.mir
+++ b/llvm/test/CodeGen/AArch64/ldst-nopreidx-sp-redzone.mir
@@ -103,8 +103,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 480
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: StackGuardSlot, type: default, offset: -40, size: 8,
@@ -216,8 +216,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 480
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: StackGuardSlot, type: default, offset: -40, size: 8,
@@ -327,8 +327,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 480
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: StackGuardSlot, type: default, offset: -40, size: 8,
diff --git a/llvm/test/CodeGen/AArch64/live-debugvalues-sve.mir b/llvm/test/CodeGen/AArch64/live-debugvalues-sve.mir
index 612453ab53f438..4be16228814a3b 100644
--- a/llvm/test/CodeGen/AArch64/live-debugvalues-sve.mir
+++ b/llvm/test/CodeGen/AArch64/live-debugvalues-sve.mir
@@ -120,8 +120,10 @@ frameInfo:
adjustsStack: true
hasC...
[truncated]
|
@llvm/pr-subscribers-backend-nvptx Author: Elizaveta Noskova (enoskova-sc) ChangesCurrently mir supports only one save and one restore point specification:
This patch provide possibility to have multiple save and multiple restore points in mir:
Shrink-Wrap points split Part 3. Part 1: #117862 Patch is 276.31 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/119357.diff 340 Files Affected:
diff --git a/llvm/include/llvm/CodeGen/MIRYamlMapping.h b/llvm/include/llvm/CodeGen/MIRYamlMapping.h
index 09a6ca936fe1f4..be8a8e593ef922 100644
--- a/llvm/include/llvm/CodeGen/MIRYamlMapping.h
+++ b/llvm/include/llvm/CodeGen/MIRYamlMapping.h
@@ -610,6 +610,20 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineJumpTable::Entry)
namespace llvm {
namespace yaml {
+struct SRPEntry {
+ StringValue Point;
+
+ bool operator==(const SRPEntry &Other) const { return Point == Other.Point; }
+};
+
+using SaveRestorePoints = std::vector<SRPEntry>;
+
+template <> struct MappingTraits<SRPEntry> {
+ static void mapping(IO &YamlIO, SRPEntry &Entry) {
+ YamlIO.mapRequired("point", Entry.Point);
+ }
+};
+
template <> struct MappingTraits<MachineJumpTable> {
static void mapping(IO &YamlIO, MachineJumpTable &JT) {
YamlIO.mapRequired("kind", JT.Kind);
@@ -618,6 +632,14 @@ template <> struct MappingTraits<MachineJumpTable> {
}
};
+} // namespace yaml
+} // namespace llvm
+
+LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::SRPEntry)
+
+namespace llvm {
+namespace yaml {
+
/// Serializable representation of MachineFrameInfo.
///
/// Doesn't serialize attributes like 'StackAlignment', 'IsStackRealignable' and
@@ -645,8 +667,8 @@ struct MachineFrameInfo {
bool HasTailCall = false;
bool IsCalleeSavedInfoValid = false;
unsigned LocalFrameSize = 0;
- StringValue SavePoint;
- StringValue RestorePoint;
+ SaveRestorePoints SavePoints;
+ SaveRestorePoints RestorePoints;
bool operator==(const MachineFrameInfo &Other) const {
return IsFrameAddressTaken == Other.IsFrameAddressTaken &&
@@ -667,7 +689,8 @@ struct MachineFrameInfo {
HasMustTailInVarArgFunc == Other.HasMustTailInVarArgFunc &&
HasTailCall == Other.HasTailCall &&
LocalFrameSize == Other.LocalFrameSize &&
- SavePoint == Other.SavePoint && RestorePoint == Other.RestorePoint &&
+ SavePoints == Other.SavePoints &&
+ RestorePoints == Other.RestorePoints &&
IsCalleeSavedInfoValid == Other.IsCalleeSavedInfoValid;
}
};
@@ -699,10 +722,12 @@ template <> struct MappingTraits<MachineFrameInfo> {
YamlIO.mapOptional("isCalleeSavedInfoValid", MFI.IsCalleeSavedInfoValid,
false);
YamlIO.mapOptional("localFrameSize", MFI.LocalFrameSize, (unsigned)0);
- YamlIO.mapOptional("savePoint", MFI.SavePoint,
- StringValue()); // Don't print it out when it's empty.
- YamlIO.mapOptional("restorePoint", MFI.RestorePoint,
- StringValue()); // Don't print it out when it's empty.
+ YamlIO.mapOptional(
+ "savePoints", MFI.SavePoints,
+ SaveRestorePoints()); // Don't print it out when it's empty.
+ YamlIO.mapOptional(
+ "restorePoints", MFI.RestorePoints,
+ SaveRestorePoints()); // Don't print it out when it's empty.
}
};
diff --git a/llvm/include/llvm/CodeGen/MachineDominators.h b/llvm/include/llvm/CodeGen/MachineDominators.h
index 74cf94398736dd..88800d91ef51a9 100644
--- a/llvm/include/llvm/CodeGen/MachineDominators.h
+++ b/llvm/include/llvm/CodeGen/MachineDominators.h
@@ -185,6 +185,11 @@ class MachineDominatorTree : public DomTreeBase<MachineBasicBlock> {
return Base::findNearestCommonDominator(A, B);
}
+ /// Returns the nearest common dominator of the given blocks.
+ /// If that tree node is a virtual root, a nullptr will be returned.
+ MachineBasicBlock *
+ findNearestCommonDominator(ArrayRef<MachineBasicBlock *> Blocks) const;
+
MachineDomTreeNode *operator[](MachineBasicBlock *BB) const {
applySplitCriticalEdges();
return Base::getNode(BB);
diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
index e2543f883f91ce..f7c1e162d2a96e 100644
--- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
@@ -124,6 +124,10 @@ class MIRParserImpl {
bool initializeFrameInfo(PerFunctionMIParsingState &PFS,
const yaml::MachineFunction &YamlMF);
+ bool initializeSaveRestorePoints(PerFunctionMIParsingState &PFS,
+ const yaml::SaveRestorePoints &YamlSRP,
+ bool IsSavePoints);
+
bool initializeCallSiteInfo(PerFunctionMIParsingState &PFS,
const yaml::MachineFunction &YamlMF);
@@ -832,18 +836,9 @@ bool MIRParserImpl::initializeFrameInfo(PerFunctionMIParsingState &PFS,
MFI.setHasTailCall(YamlMFI.HasTailCall);
MFI.setCalleeSavedInfoValid(YamlMFI.IsCalleeSavedInfoValid);
MFI.setLocalFrameSize(YamlMFI.LocalFrameSize);
- if (!YamlMFI.SavePoint.Value.empty()) {
- MachineBasicBlock *MBB = nullptr;
- if (parseMBBReference(PFS, MBB, YamlMFI.SavePoint))
- return true;
- MFI.setSavePoint(MBB);
- }
- if (!YamlMFI.RestorePoint.Value.empty()) {
- MachineBasicBlock *MBB = nullptr;
- if (parseMBBReference(PFS, MBB, YamlMFI.RestorePoint))
- return true;
- MFI.setRestorePoint(MBB);
- }
+ initializeSaveRestorePoints(PFS, YamlMFI.SavePoints, true /*IsSavePoints*/);
+ initializeSaveRestorePoints(PFS, YamlMFI.RestorePoints,
+ false /*IsSavePoints*/);
std::vector<CalleeSavedInfo> CSIInfo;
// Initialize the fixed frame objects.
@@ -1058,8 +1053,28 @@ bool MIRParserImpl::initializeConstantPool(PerFunctionMIParsingState &PFS,
return false;
}
-bool MIRParserImpl::initializeJumpTableInfo(PerFunctionMIParsingState &PFS,
- const yaml::MachineJumpTable &YamlJTI) {
+bool MIRParserImpl::initializeSaveRestorePoints(
+ PerFunctionMIParsingState &PFS, const yaml::SaveRestorePoints &YamlSRP,
+ bool IsSavePoints) {
+ MachineFunction &MF = PFS.MF;
+ MachineFrameInfo &MFI = MF.getFrameInfo();
+
+ if (!YamlSRP.empty()) {
+ const auto &Entry = YamlSRP.front();
+ const auto &MBBSource = Entry.Point;
+ MachineBasicBlock *MBB = nullptr;
+ if (parseMBBReference(PFS, MBB, MBBSource.Value))
+ return true;
+ if (IsSavePoints)
+ MFI.setSavePoint(MBB);
+ else
+ MFI.setRestorePoint(MBB);
+ }
+ return false;
+}
+
+bool MIRParserImpl::initializeJumpTableInfo(
+ PerFunctionMIParsingState &PFS, const yaml::MachineJumpTable &YamlJTI) {
MachineJumpTableInfo *JTI = PFS.MF.getOrCreateJumpTableInfo(YamlJTI.Kind);
for (const auto &Entry : YamlJTI.Entries) {
std::vector<MachineBasicBlock *> Blocks;
diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp
index c8f6341c1224d2..2d0728a6452808 100644
--- a/llvm/lib/CodeGen/MIRPrinter.cpp
+++ b/llvm/lib/CodeGen/MIRPrinter.cpp
@@ -118,6 +118,8 @@ class MIRPrinter {
const TargetRegisterInfo *TRI);
void convert(ModuleSlotTracker &MST, yaml::MachineFrameInfo &YamlMFI,
const MachineFrameInfo &MFI);
+ void convert(ModuleSlotTracker &MST, yaml::SaveRestorePoints &YamlSRP,
+ MachineBasicBlock *SaveRestorePoint);
void convert(yaml::MachineFunction &MF,
const MachineConstantPool &ConstantPool);
void convert(ModuleSlotTracker &MST, yaml::MachineJumpTable &YamlJTI,
@@ -392,14 +394,10 @@ void MIRPrinter::convert(ModuleSlotTracker &MST,
YamlMFI.HasTailCall = MFI.hasTailCall();
YamlMFI.IsCalleeSavedInfoValid = MFI.isCalleeSavedInfoValid();
YamlMFI.LocalFrameSize = MFI.getLocalFrameSize();
- if (MFI.getSavePoint()) {
- raw_string_ostream StrOS(YamlMFI.SavePoint.Value);
- StrOS << printMBBReference(*MFI.getSavePoint());
- }
- if (MFI.getRestorePoint()) {
- raw_string_ostream StrOS(YamlMFI.RestorePoint.Value);
- StrOS << printMBBReference(*MFI.getRestorePoint());
- }
+ if (MFI.getSavePoint())
+ convert(MST, YamlMFI.SavePoints, MFI.getSavePoint());
+ if (MFI.getRestorePoint())
+ convert(MST, YamlMFI.RestorePoints, MFI.getRestorePoint());
}
void MIRPrinter::convertEntryValueObjects(yaml::MachineFunction &YMF,
@@ -618,6 +616,18 @@ void MIRPrinter::convert(yaml::MachineFunction &MF,
}
}
+void MIRPrinter::convert(ModuleSlotTracker &MST,
+ yaml::SaveRestorePoints &YamlSRP,
+ MachineBasicBlock *SRP) {
+ std::string Str;
+ yaml::SRPEntry Entry;
+ raw_string_ostream StrOS(Str);
+ StrOS << printMBBReference(*SRP);
+ Entry.Point = StrOS.str();
+ Str.clear();
+ YamlSRP.push_back(Entry);
+}
+
void MIRPrinter::convert(ModuleSlotTracker &MST,
yaml::MachineJumpTable &YamlJTI,
const MachineJumpTableInfo &JTI) {
diff --git a/llvm/lib/CodeGen/MachineDominators.cpp b/llvm/lib/CodeGen/MachineDominators.cpp
index a2cc8fdfa7c9f9..384f90c6da66c0 100644
--- a/llvm/lib/CodeGen/MachineDominators.cpp
+++ b/llvm/lib/CodeGen/MachineDominators.cpp
@@ -189,3 +189,19 @@ void MachineDominatorTree::applySplitCriticalEdges() const {
NewBBs.clear();
CriticalEdgesToSplit.clear();
}
+
+MachineBasicBlock *MachineDominatorTree::findNearestCommonDominator(
+ ArrayRef<MachineBasicBlock *> Blocks) const {
+ assert(!Blocks.empty());
+
+ MachineBasicBlock *NCD = Blocks.front();
+ for (MachineBasicBlock *BB : Blocks.drop_front()) {
+ NCD = Base::findNearestCommonDominator(NCD, BB);
+
+ // Stop when the root is reached.
+ if (Base::isVirtualRoot(Base::getNode(NCD)))
+ return nullptr;
+ }
+
+ return NCD;
+}
diff --git a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
index deb0b627225c64..0de1f1d821a6e2 100644
--- a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
@@ -1607,6 +1607,8 @@ bool RISCVFrameLowering::assignCalleeSavedSpillSlots(
int FrameIdx = MFI.CreateFixedSpillStackObject(Size, Offset);
assert(FrameIdx < 0);
CS.setFrameIdx(FrameIdx);
+ if (RISCVRegisterInfo::isRVVRegClass(RC))
+ MFI.setStackID(FrameIdx, TargetStackID::ScalableVector);
continue;
}
}
@@ -1623,6 +1625,8 @@ bool RISCVFrameLowering::assignCalleeSavedSpillSlots(
if ((unsigned)FrameIdx > MaxCSFrameIndex)
MaxCSFrameIndex = FrameIdx;
CS.setFrameIdx(FrameIdx);
+ if (RISCVRegisterInfo::isRVVRegClass(RC))
+ MFI.setStackID(FrameIdx, TargetStackID::ScalableVector);
}
// Allocate a fixed object that covers the full push or libcall size.
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/store-merging-debug.mir b/llvm/test/CodeGen/AArch64/GlobalISel/store-merging-debug.mir
index d52ef0f3da74c7..2e8f3c460b2fe7 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/store-merging-debug.mir
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/store-merging-debug.mir
@@ -86,8 +86,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack: []
callSites: []
diff --git a/llvm/test/CodeGen/AArch64/aarch64-ldst-no-premature-sp-pop.mir b/llvm/test/CodeGen/AArch64/aarch64-ldst-no-premature-sp-pop.mir
index ba621cf77f9aed..07e80538e793f5 100644
--- a/llvm/test/CodeGen/AArch64/aarch64-ldst-no-premature-sp-pop.mir
+++ b/llvm/test/CodeGen/AArch64/aarch64-ldst-no-premature-sp-pop.mir
@@ -59,8 +59,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 16
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, type: default, offset: -16, size: 16,
diff --git a/llvm/test/CodeGen/AArch64/aarch64-mov-debug-locs.mir b/llvm/test/CodeGen/AArch64/aarch64-mov-debug-locs.mir
index 16e2de751381ad..31589a86599ff3 100644
--- a/llvm/test/CodeGen/AArch64/aarch64-mov-debug-locs.mir
+++ b/llvm/test/CodeGen/AArch64/aarch64-mov-debug-locs.mir
@@ -157,8 +157,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8,
diff --git a/llvm/test/CodeGen/AArch64/aarch64st1.mir b/llvm/test/CodeGen/AArch64/aarch64st1.mir
index 22a024d37bc64f..439db1e97aa794 100644
--- a/llvm/test/CodeGen/AArch64/aarch64st1.mir
+++ b/llvm/test/CodeGen/AArch64/aarch64st1.mir
@@ -58,8 +58,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: default, offset: 0, size: 4, alignment: 4,
diff --git a/llvm/test/CodeGen/AArch64/cfi-fixup-multi-block-prologue.mir b/llvm/test/CodeGen/AArch64/cfi-fixup-multi-block-prologue.mir
index 31fa3832367bec..6851fdba1239a4 100644
--- a/llvm/test/CodeGen/AArch64/cfi-fixup-multi-block-prologue.mir
+++ b/llvm/test/CodeGen/AArch64/cfi-fixup-multi-block-prologue.mir
@@ -80,8 +80,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 30000
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: p, type: default, offset: -30016, size: 30000, alignment: 1,
diff --git a/llvm/test/CodeGen/AArch64/cfi-fixup-multi-section.mir b/llvm/test/CodeGen/AArch64/cfi-fixup-multi-section.mir
index a24972d1388320..fe5c90a5e6dc54 100644
--- a/llvm/test/CodeGen/AArch64/cfi-fixup-multi-section.mir
+++ b/llvm/test/CodeGen/AArch64/cfi-fixup-multi-section.mir
@@ -47,8 +47,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: spill-slot, offset: -16, size: 8, alignment: 16,
diff --git a/llvm/test/CodeGen/AArch64/cfi-fixup.mir b/llvm/test/CodeGen/AArch64/cfi-fixup.mir
index f522df6bb3fa06..dd75cec7f6e0be 100644
--- a/llvm/test/CodeGen/AArch64/cfi-fixup.mir
+++ b/llvm/test/CodeGen/AArch64/cfi-fixup.mir
@@ -65,8 +65,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: spill-slot, offset: -16, size: 8, alignment: 16,
@@ -248,8 +248,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: spill-slot, offset: -16, size: 8, alignment: 16,
@@ -403,8 +403,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: spill-slot, offset: -16, size: 8, alignment: 16,
diff --git a/llvm/test/CodeGen/AArch64/dont-shrink-wrap-stack-mayloadorstore.mir b/llvm/test/CodeGen/AArch64/dont-shrink-wrap-stack-mayloadorstore.mir
index 1c4447bffd8729..85f8abcbf7fe60 100644
--- a/llvm/test/CodeGen/AArch64/dont-shrink-wrap-stack-mayloadorstore.mir
+++ b/llvm/test/CodeGen/AArch64/dont-shrink-wrap-stack-mayloadorstore.mir
@@ -6,17 +6,23 @@
; RUN: llc -x=mir -simplify-mir -run-pass=shrink-wrap -o - %s | FileCheck %s
; CHECK: name: compiler_pop_stack
; CHECK: frameInfo:
- ; CHECK: savePoint: '%bb.1'
- ; CHECK: restorePoint: '%bb.7'
+ ; CHECK: savePoints:
+ ; CHECK-NEXT: - point: '%bb.1'
+ ; CHECK: restorePoints:
+ ; CHECK-NEXT: - point: '%bb.7'
; CHECK: name: compiler_pop_stack_no_memoperands
; CHECK: frameInfo:
- ; CHECK: savePoint: '%bb.1'
- ; CHECK: restorePoint: '%bb.7'
+ ; CHECK: savePoints:
+ ; CHECK-NEXT: - point: '%bb.1'
+ ; CHECK: restorePoints:
+ ; CHECK-NEXT: - point: '%bb.7'
; CHECK: name: f
; CHECK: frameInfo:
- ; CHECK: savePoint: '%bb.2'
- ; CHECK-NEXT: restorePoint: '%bb.4'
- ; CHECK-NEXT: stack:
+ ; CHECK: savePoints:
+ ; CHECK-NEXT: - point: '%bb.2'
+ ; CHECK: restorePoints:
+ ; CHECK-NEXT: - point: '%bb.4'
+ ; CHECK: stack:
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64"
diff --git a/llvm/test/CodeGen/AArch64/early-ifcvt-regclass-mismatch.mir b/llvm/test/CodeGen/AArch64/early-ifcvt-regclass-mismatch.mir
index a7f67f8b682c3c..6324db0cb2c0ff 100644
--- a/llvm/test/CodeGen/AArch64/early-ifcvt-regclass-mismatch.mir
+++ b/llvm/test/CodeGen/AArch64/early-ifcvt-regclass-mismatch.mir
@@ -105,8 +105,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack: []
callSites: []
diff --git a/llvm/test/CodeGen/AArch64/emit_fneg_with_non_register_operand.mir b/llvm/test/CodeGen/AArch64/emit_fneg_with_non_register_operand.mir
index f9878adfe5e448..3c98a1a128413e 100644
--- a/llvm/test/CodeGen/AArch64/emit_fneg_with_non_register_operand.mir
+++ b/llvm/test/CodeGen/AArch64/emit_fneg_with_non_register_operand.mir
@@ -75,8 +75,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: true
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack: []
entry_values: []
diff --git a/llvm/test/CodeGen/AArch64/irg-nomem.mir b/llvm/test/CodeGen/AArch64/irg-nomem.mir
index 3b000fafbed46f..78438151405e66 100644
--- a/llvm/test/CodeGen/AArch64/irg-nomem.mir
+++ b/llvm/test/CodeGen/AArch64/irg-nomem.mir
@@ -47,8 +47,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack: []
callSites: []
diff --git a/llvm/test/CodeGen/AArch64/jump-table-duplicate.mir b/llvm/test/CodeGen/AArch64/jump-table-duplicate.mir
index a2532a854923f5..81cf5953895cab 100644
--- a/llvm/test/CodeGen/AArch64/jump-table-duplicate.mir
+++ b/llvm/test/CodeGen/AArch64/jump-table-duplicate.mir
@@ -92,8 +92,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8,
diff --git a/llvm/test/CodeGen/AArch64/ldst-nopreidx-sp-redzone.mir b/llvm/test/CodeGen/AArch64/ldst-nopreidx-sp-redzone.mir
index f1f9e5fbc9b087..b431de2d9b35b3 100644
--- a/llvm/test/CodeGen/AArch64/ldst-nopreidx-sp-redzone.mir
+++ b/llvm/test/CodeGen/AArch64/ldst-nopreidx-sp-redzone.mir
@@ -103,8 +103,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 480
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: StackGuardSlot, type: default, offset: -40, size: 8,
@@ -216,8 +216,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 480
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: StackGuardSlot, type: default, offset: -40, size: 8,
@@ -327,8 +327,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 480
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: StackGuardSlot, type: default, offset: -40, size: 8,
diff --git a/llvm/test/CodeGen/AArch64/live-debugvalues-sve.mir b/llvm/test/CodeGen/AArch64/live-debugvalues-sve.mir
index 612453ab53f438..4be16228814a3b 100644
--- a/llvm/test/CodeGen/AArch64/live-debugvalues-sve.mir
+++ b/llvm/test/CodeGen/AArch64/live-debugvalues-sve.mir
@@ -120,8 +120,10 @@ frameInfo:
adjustsStack: true
hasC...
[truncated]
|
@llvm/pr-subscribers-backend-powerpc Author: Elizaveta Noskova (enoskova-sc) ChangesCurrently mir supports only one save and one restore point specification:
This patch provide possibility to have multiple save and multiple restore points in mir:
Shrink-Wrap points split Part 3. Part 1: #117862 Patch is 276.31 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/119357.diff 340 Files Affected:
diff --git a/llvm/include/llvm/CodeGen/MIRYamlMapping.h b/llvm/include/llvm/CodeGen/MIRYamlMapping.h
index 09a6ca936fe1f4..be8a8e593ef922 100644
--- a/llvm/include/llvm/CodeGen/MIRYamlMapping.h
+++ b/llvm/include/llvm/CodeGen/MIRYamlMapping.h
@@ -610,6 +610,20 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineJumpTable::Entry)
namespace llvm {
namespace yaml {
+struct SRPEntry {
+ StringValue Point;
+
+ bool operator==(const SRPEntry &Other) const { return Point == Other.Point; }
+};
+
+using SaveRestorePoints = std::vector<SRPEntry>;
+
+template <> struct MappingTraits<SRPEntry> {
+ static void mapping(IO &YamlIO, SRPEntry &Entry) {
+ YamlIO.mapRequired("point", Entry.Point);
+ }
+};
+
template <> struct MappingTraits<MachineJumpTable> {
static void mapping(IO &YamlIO, MachineJumpTable &JT) {
YamlIO.mapRequired("kind", JT.Kind);
@@ -618,6 +632,14 @@ template <> struct MappingTraits<MachineJumpTable> {
}
};
+} // namespace yaml
+} // namespace llvm
+
+LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::SRPEntry)
+
+namespace llvm {
+namespace yaml {
+
/// Serializable representation of MachineFrameInfo.
///
/// Doesn't serialize attributes like 'StackAlignment', 'IsStackRealignable' and
@@ -645,8 +667,8 @@ struct MachineFrameInfo {
bool HasTailCall = false;
bool IsCalleeSavedInfoValid = false;
unsigned LocalFrameSize = 0;
- StringValue SavePoint;
- StringValue RestorePoint;
+ SaveRestorePoints SavePoints;
+ SaveRestorePoints RestorePoints;
bool operator==(const MachineFrameInfo &Other) const {
return IsFrameAddressTaken == Other.IsFrameAddressTaken &&
@@ -667,7 +689,8 @@ struct MachineFrameInfo {
HasMustTailInVarArgFunc == Other.HasMustTailInVarArgFunc &&
HasTailCall == Other.HasTailCall &&
LocalFrameSize == Other.LocalFrameSize &&
- SavePoint == Other.SavePoint && RestorePoint == Other.RestorePoint &&
+ SavePoints == Other.SavePoints &&
+ RestorePoints == Other.RestorePoints &&
IsCalleeSavedInfoValid == Other.IsCalleeSavedInfoValid;
}
};
@@ -699,10 +722,12 @@ template <> struct MappingTraits<MachineFrameInfo> {
YamlIO.mapOptional("isCalleeSavedInfoValid", MFI.IsCalleeSavedInfoValid,
false);
YamlIO.mapOptional("localFrameSize", MFI.LocalFrameSize, (unsigned)0);
- YamlIO.mapOptional("savePoint", MFI.SavePoint,
- StringValue()); // Don't print it out when it's empty.
- YamlIO.mapOptional("restorePoint", MFI.RestorePoint,
- StringValue()); // Don't print it out when it's empty.
+ YamlIO.mapOptional(
+ "savePoints", MFI.SavePoints,
+ SaveRestorePoints()); // Don't print it out when it's empty.
+ YamlIO.mapOptional(
+ "restorePoints", MFI.RestorePoints,
+ SaveRestorePoints()); // Don't print it out when it's empty.
}
};
diff --git a/llvm/include/llvm/CodeGen/MachineDominators.h b/llvm/include/llvm/CodeGen/MachineDominators.h
index 74cf94398736dd..88800d91ef51a9 100644
--- a/llvm/include/llvm/CodeGen/MachineDominators.h
+++ b/llvm/include/llvm/CodeGen/MachineDominators.h
@@ -185,6 +185,11 @@ class MachineDominatorTree : public DomTreeBase<MachineBasicBlock> {
return Base::findNearestCommonDominator(A, B);
}
+ /// Returns the nearest common dominator of the given blocks.
+ /// If that tree node is a virtual root, a nullptr will be returned.
+ MachineBasicBlock *
+ findNearestCommonDominator(ArrayRef<MachineBasicBlock *> Blocks) const;
+
MachineDomTreeNode *operator[](MachineBasicBlock *BB) const {
applySplitCriticalEdges();
return Base::getNode(BB);
diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
index e2543f883f91ce..f7c1e162d2a96e 100644
--- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
@@ -124,6 +124,10 @@ class MIRParserImpl {
bool initializeFrameInfo(PerFunctionMIParsingState &PFS,
const yaml::MachineFunction &YamlMF);
+ bool initializeSaveRestorePoints(PerFunctionMIParsingState &PFS,
+ const yaml::SaveRestorePoints &YamlSRP,
+ bool IsSavePoints);
+
bool initializeCallSiteInfo(PerFunctionMIParsingState &PFS,
const yaml::MachineFunction &YamlMF);
@@ -832,18 +836,9 @@ bool MIRParserImpl::initializeFrameInfo(PerFunctionMIParsingState &PFS,
MFI.setHasTailCall(YamlMFI.HasTailCall);
MFI.setCalleeSavedInfoValid(YamlMFI.IsCalleeSavedInfoValid);
MFI.setLocalFrameSize(YamlMFI.LocalFrameSize);
- if (!YamlMFI.SavePoint.Value.empty()) {
- MachineBasicBlock *MBB = nullptr;
- if (parseMBBReference(PFS, MBB, YamlMFI.SavePoint))
- return true;
- MFI.setSavePoint(MBB);
- }
- if (!YamlMFI.RestorePoint.Value.empty()) {
- MachineBasicBlock *MBB = nullptr;
- if (parseMBBReference(PFS, MBB, YamlMFI.RestorePoint))
- return true;
- MFI.setRestorePoint(MBB);
- }
+ initializeSaveRestorePoints(PFS, YamlMFI.SavePoints, true /*IsSavePoints*/);
+ initializeSaveRestorePoints(PFS, YamlMFI.RestorePoints,
+ false /*IsSavePoints*/);
std::vector<CalleeSavedInfo> CSIInfo;
// Initialize the fixed frame objects.
@@ -1058,8 +1053,28 @@ bool MIRParserImpl::initializeConstantPool(PerFunctionMIParsingState &PFS,
return false;
}
-bool MIRParserImpl::initializeJumpTableInfo(PerFunctionMIParsingState &PFS,
- const yaml::MachineJumpTable &YamlJTI) {
+bool MIRParserImpl::initializeSaveRestorePoints(
+ PerFunctionMIParsingState &PFS, const yaml::SaveRestorePoints &YamlSRP,
+ bool IsSavePoints) {
+ MachineFunction &MF = PFS.MF;
+ MachineFrameInfo &MFI = MF.getFrameInfo();
+
+ if (!YamlSRP.empty()) {
+ const auto &Entry = YamlSRP.front();
+ const auto &MBBSource = Entry.Point;
+ MachineBasicBlock *MBB = nullptr;
+ if (parseMBBReference(PFS, MBB, MBBSource.Value))
+ return true;
+ if (IsSavePoints)
+ MFI.setSavePoint(MBB);
+ else
+ MFI.setRestorePoint(MBB);
+ }
+ return false;
+}
+
+bool MIRParserImpl::initializeJumpTableInfo(
+ PerFunctionMIParsingState &PFS, const yaml::MachineJumpTable &YamlJTI) {
MachineJumpTableInfo *JTI = PFS.MF.getOrCreateJumpTableInfo(YamlJTI.Kind);
for (const auto &Entry : YamlJTI.Entries) {
std::vector<MachineBasicBlock *> Blocks;
diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp
index c8f6341c1224d2..2d0728a6452808 100644
--- a/llvm/lib/CodeGen/MIRPrinter.cpp
+++ b/llvm/lib/CodeGen/MIRPrinter.cpp
@@ -118,6 +118,8 @@ class MIRPrinter {
const TargetRegisterInfo *TRI);
void convert(ModuleSlotTracker &MST, yaml::MachineFrameInfo &YamlMFI,
const MachineFrameInfo &MFI);
+ void convert(ModuleSlotTracker &MST, yaml::SaveRestorePoints &YamlSRP,
+ MachineBasicBlock *SaveRestorePoint);
void convert(yaml::MachineFunction &MF,
const MachineConstantPool &ConstantPool);
void convert(ModuleSlotTracker &MST, yaml::MachineJumpTable &YamlJTI,
@@ -392,14 +394,10 @@ void MIRPrinter::convert(ModuleSlotTracker &MST,
YamlMFI.HasTailCall = MFI.hasTailCall();
YamlMFI.IsCalleeSavedInfoValid = MFI.isCalleeSavedInfoValid();
YamlMFI.LocalFrameSize = MFI.getLocalFrameSize();
- if (MFI.getSavePoint()) {
- raw_string_ostream StrOS(YamlMFI.SavePoint.Value);
- StrOS << printMBBReference(*MFI.getSavePoint());
- }
- if (MFI.getRestorePoint()) {
- raw_string_ostream StrOS(YamlMFI.RestorePoint.Value);
- StrOS << printMBBReference(*MFI.getRestorePoint());
- }
+ if (MFI.getSavePoint())
+ convert(MST, YamlMFI.SavePoints, MFI.getSavePoint());
+ if (MFI.getRestorePoint())
+ convert(MST, YamlMFI.RestorePoints, MFI.getRestorePoint());
}
void MIRPrinter::convertEntryValueObjects(yaml::MachineFunction &YMF,
@@ -618,6 +616,18 @@ void MIRPrinter::convert(yaml::MachineFunction &MF,
}
}
+void MIRPrinter::convert(ModuleSlotTracker &MST,
+ yaml::SaveRestorePoints &YamlSRP,
+ MachineBasicBlock *SRP) {
+ std::string Str;
+ yaml::SRPEntry Entry;
+ raw_string_ostream StrOS(Str);
+ StrOS << printMBBReference(*SRP);
+ Entry.Point = StrOS.str();
+ Str.clear();
+ YamlSRP.push_back(Entry);
+}
+
void MIRPrinter::convert(ModuleSlotTracker &MST,
yaml::MachineJumpTable &YamlJTI,
const MachineJumpTableInfo &JTI) {
diff --git a/llvm/lib/CodeGen/MachineDominators.cpp b/llvm/lib/CodeGen/MachineDominators.cpp
index a2cc8fdfa7c9f9..384f90c6da66c0 100644
--- a/llvm/lib/CodeGen/MachineDominators.cpp
+++ b/llvm/lib/CodeGen/MachineDominators.cpp
@@ -189,3 +189,19 @@ void MachineDominatorTree::applySplitCriticalEdges() const {
NewBBs.clear();
CriticalEdgesToSplit.clear();
}
+
+MachineBasicBlock *MachineDominatorTree::findNearestCommonDominator(
+ ArrayRef<MachineBasicBlock *> Blocks) const {
+ assert(!Blocks.empty());
+
+ MachineBasicBlock *NCD = Blocks.front();
+ for (MachineBasicBlock *BB : Blocks.drop_front()) {
+ NCD = Base::findNearestCommonDominator(NCD, BB);
+
+ // Stop when the root is reached.
+ if (Base::isVirtualRoot(Base::getNode(NCD)))
+ return nullptr;
+ }
+
+ return NCD;
+}
diff --git a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
index deb0b627225c64..0de1f1d821a6e2 100644
--- a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
@@ -1607,6 +1607,8 @@ bool RISCVFrameLowering::assignCalleeSavedSpillSlots(
int FrameIdx = MFI.CreateFixedSpillStackObject(Size, Offset);
assert(FrameIdx < 0);
CS.setFrameIdx(FrameIdx);
+ if (RISCVRegisterInfo::isRVVRegClass(RC))
+ MFI.setStackID(FrameIdx, TargetStackID::ScalableVector);
continue;
}
}
@@ -1623,6 +1625,8 @@ bool RISCVFrameLowering::assignCalleeSavedSpillSlots(
if ((unsigned)FrameIdx > MaxCSFrameIndex)
MaxCSFrameIndex = FrameIdx;
CS.setFrameIdx(FrameIdx);
+ if (RISCVRegisterInfo::isRVVRegClass(RC))
+ MFI.setStackID(FrameIdx, TargetStackID::ScalableVector);
}
// Allocate a fixed object that covers the full push or libcall size.
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/store-merging-debug.mir b/llvm/test/CodeGen/AArch64/GlobalISel/store-merging-debug.mir
index d52ef0f3da74c7..2e8f3c460b2fe7 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/store-merging-debug.mir
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/store-merging-debug.mir
@@ -86,8 +86,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack: []
callSites: []
diff --git a/llvm/test/CodeGen/AArch64/aarch64-ldst-no-premature-sp-pop.mir b/llvm/test/CodeGen/AArch64/aarch64-ldst-no-premature-sp-pop.mir
index ba621cf77f9aed..07e80538e793f5 100644
--- a/llvm/test/CodeGen/AArch64/aarch64-ldst-no-premature-sp-pop.mir
+++ b/llvm/test/CodeGen/AArch64/aarch64-ldst-no-premature-sp-pop.mir
@@ -59,8 +59,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 16
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, type: default, offset: -16, size: 16,
diff --git a/llvm/test/CodeGen/AArch64/aarch64-mov-debug-locs.mir b/llvm/test/CodeGen/AArch64/aarch64-mov-debug-locs.mir
index 16e2de751381ad..31589a86599ff3 100644
--- a/llvm/test/CodeGen/AArch64/aarch64-mov-debug-locs.mir
+++ b/llvm/test/CodeGen/AArch64/aarch64-mov-debug-locs.mir
@@ -157,8 +157,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8,
diff --git a/llvm/test/CodeGen/AArch64/aarch64st1.mir b/llvm/test/CodeGen/AArch64/aarch64st1.mir
index 22a024d37bc64f..439db1e97aa794 100644
--- a/llvm/test/CodeGen/AArch64/aarch64st1.mir
+++ b/llvm/test/CodeGen/AArch64/aarch64st1.mir
@@ -58,8 +58,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: default, offset: 0, size: 4, alignment: 4,
diff --git a/llvm/test/CodeGen/AArch64/cfi-fixup-multi-block-prologue.mir b/llvm/test/CodeGen/AArch64/cfi-fixup-multi-block-prologue.mir
index 31fa3832367bec..6851fdba1239a4 100644
--- a/llvm/test/CodeGen/AArch64/cfi-fixup-multi-block-prologue.mir
+++ b/llvm/test/CodeGen/AArch64/cfi-fixup-multi-block-prologue.mir
@@ -80,8 +80,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 30000
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: p, type: default, offset: -30016, size: 30000, alignment: 1,
diff --git a/llvm/test/CodeGen/AArch64/cfi-fixup-multi-section.mir b/llvm/test/CodeGen/AArch64/cfi-fixup-multi-section.mir
index a24972d1388320..fe5c90a5e6dc54 100644
--- a/llvm/test/CodeGen/AArch64/cfi-fixup-multi-section.mir
+++ b/llvm/test/CodeGen/AArch64/cfi-fixup-multi-section.mir
@@ -47,8 +47,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: spill-slot, offset: -16, size: 8, alignment: 16,
diff --git a/llvm/test/CodeGen/AArch64/cfi-fixup.mir b/llvm/test/CodeGen/AArch64/cfi-fixup.mir
index f522df6bb3fa06..dd75cec7f6e0be 100644
--- a/llvm/test/CodeGen/AArch64/cfi-fixup.mir
+++ b/llvm/test/CodeGen/AArch64/cfi-fixup.mir
@@ -65,8 +65,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: spill-slot, offset: -16, size: 8, alignment: 16,
@@ -248,8 +248,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: spill-slot, offset: -16, size: 8, alignment: 16,
@@ -403,8 +403,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: spill-slot, offset: -16, size: 8, alignment: 16,
diff --git a/llvm/test/CodeGen/AArch64/dont-shrink-wrap-stack-mayloadorstore.mir b/llvm/test/CodeGen/AArch64/dont-shrink-wrap-stack-mayloadorstore.mir
index 1c4447bffd8729..85f8abcbf7fe60 100644
--- a/llvm/test/CodeGen/AArch64/dont-shrink-wrap-stack-mayloadorstore.mir
+++ b/llvm/test/CodeGen/AArch64/dont-shrink-wrap-stack-mayloadorstore.mir
@@ -6,17 +6,23 @@
; RUN: llc -x=mir -simplify-mir -run-pass=shrink-wrap -o - %s | FileCheck %s
; CHECK: name: compiler_pop_stack
; CHECK: frameInfo:
- ; CHECK: savePoint: '%bb.1'
- ; CHECK: restorePoint: '%bb.7'
+ ; CHECK: savePoints:
+ ; CHECK-NEXT: - point: '%bb.1'
+ ; CHECK: restorePoints:
+ ; CHECK-NEXT: - point: '%bb.7'
; CHECK: name: compiler_pop_stack_no_memoperands
; CHECK: frameInfo:
- ; CHECK: savePoint: '%bb.1'
- ; CHECK: restorePoint: '%bb.7'
+ ; CHECK: savePoints:
+ ; CHECK-NEXT: - point: '%bb.1'
+ ; CHECK: restorePoints:
+ ; CHECK-NEXT: - point: '%bb.7'
; CHECK: name: f
; CHECK: frameInfo:
- ; CHECK: savePoint: '%bb.2'
- ; CHECK-NEXT: restorePoint: '%bb.4'
- ; CHECK-NEXT: stack:
+ ; CHECK: savePoints:
+ ; CHECK-NEXT: - point: '%bb.2'
+ ; CHECK: restorePoints:
+ ; CHECK-NEXT: - point: '%bb.4'
+ ; CHECK: stack:
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64"
diff --git a/llvm/test/CodeGen/AArch64/early-ifcvt-regclass-mismatch.mir b/llvm/test/CodeGen/AArch64/early-ifcvt-regclass-mismatch.mir
index a7f67f8b682c3c..6324db0cb2c0ff 100644
--- a/llvm/test/CodeGen/AArch64/early-ifcvt-regclass-mismatch.mir
+++ b/llvm/test/CodeGen/AArch64/early-ifcvt-regclass-mismatch.mir
@@ -105,8 +105,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack: []
callSites: []
diff --git a/llvm/test/CodeGen/AArch64/emit_fneg_with_non_register_operand.mir b/llvm/test/CodeGen/AArch64/emit_fneg_with_non_register_operand.mir
index f9878adfe5e448..3c98a1a128413e 100644
--- a/llvm/test/CodeGen/AArch64/emit_fneg_with_non_register_operand.mir
+++ b/llvm/test/CodeGen/AArch64/emit_fneg_with_non_register_operand.mir
@@ -75,8 +75,8 @@ frameInfo:
hasMustTailInVarArgFunc: false
hasTailCall: true
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack: []
entry_values: []
diff --git a/llvm/test/CodeGen/AArch64/irg-nomem.mir b/llvm/test/CodeGen/AArch64/irg-nomem.mir
index 3b000fafbed46f..78438151405e66 100644
--- a/llvm/test/CodeGen/AArch64/irg-nomem.mir
+++ b/llvm/test/CodeGen/AArch64/irg-nomem.mir
@@ -47,8 +47,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack: []
callSites: []
diff --git a/llvm/test/CodeGen/AArch64/jump-table-duplicate.mir b/llvm/test/CodeGen/AArch64/jump-table-duplicate.mir
index a2532a854923f5..81cf5953895cab 100644
--- a/llvm/test/CodeGen/AArch64/jump-table-duplicate.mir
+++ b/llvm/test/CodeGen/AArch64/jump-table-duplicate.mir
@@ -92,8 +92,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 0
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8,
diff --git a/llvm/test/CodeGen/AArch64/ldst-nopreidx-sp-redzone.mir b/llvm/test/CodeGen/AArch64/ldst-nopreidx-sp-redzone.mir
index f1f9e5fbc9b087..b431de2d9b35b3 100644
--- a/llvm/test/CodeGen/AArch64/ldst-nopreidx-sp-redzone.mir
+++ b/llvm/test/CodeGen/AArch64/ldst-nopreidx-sp-redzone.mir
@@ -103,8 +103,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 480
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: StackGuardSlot, type: default, offset: -40, size: 8,
@@ -216,8 +216,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 480
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: StackGuardSlot, type: default, offset: -40, size: 8,
@@ -327,8 +327,8 @@ frameInfo:
hasVAStart: false
hasMustTailInVarArgFunc: false
localFrameSize: 480
- savePoint: ''
- restorePoint: ''
+ savePoints: []
+ restorePoints: []
fixedStack: []
stack:
- { id: 0, name: StackGuardSlot, type: default, offset: -40, size: 8,
diff --git a/llvm/test/CodeGen/AArch64/live-debugvalues-sve.mir b/llvm/test/CodeGen/AArch64/live-debugvalues-sve.mir
index 612453ab53f438..4be16228814a3b 100644
--- a/llvm/test/CodeGen/AArch64/live-debugvalues-sve.mir
+++ b/llvm/test/CodeGen/AArch64/live-debugvalues-sve.mir
@@ -120,8 +120,10 @@ frameInfo:
adjustsStack: true
hasC...
[truncated]
|
@arsenm, could you take a look, please. |
@@ -86,8 +86,8 @@ frameInfo: | |||
hasMustTailInVarArgFunc: false | |||
hasTailCall: false | |||
localFrameSize: 0 | |||
savePoint: '' | |||
restorePoint: '' | |||
savePoints: [] |
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.
You will cut out a huge amount of spurious diff if you teach the parser to support both the singular and plural forms here.
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.
Аddressed. Now MIR can be consumed both in singular:
savePoint: '%bb.1'
and plural:
savePoint:
- point: '%bb.1'
formats.
But printed in only plural format.
llvm/lib/CodeGen/MIRPrinter.cpp
Outdated
MachineBasicBlock *SRP) { | ||
std::string Str; | ||
yaml::SRPEntry Entry; | ||
raw_string_ostream StrOS(Str); |
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.
raw_svector_ostream + SmallVector
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.
addressed
llvm/lib/CodeGen/MIRPrinter.cpp
Outdated
raw_string_ostream StrOS(Str); | ||
StrOS << printMBBReference(*SRP); | ||
Entry.Point = StrOS.str(); | ||
Str.clear(); |
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.
Don't need this
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.
addressed
@@ -610,6 +610,20 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineJumpTable::Entry) | |||
namespace llvm { | |||
namespace yaml { | |||
|
|||
struct SRPEntry { |
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.
nit: rename to SaveRestorePointEntry
? I don't think SRP is a common acronym. Also please add a docstring.
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.
addressed
MFI.setRestorePoint(MBB); | ||
} | ||
initializeSaveRestorePoints(PFS, YamlMFI.SavePoints, true /*IsSavePoints*/); | ||
initializeSaveRestorePoints(PFS, YamlMFI.RestorePoints, |
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.
We used to return true when parseMBBReference
. Are we missing this functionality now?
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.
Addressed, now this functionality isn't missed.
return false; | ||
} | ||
|
||
bool MIRParserImpl::initializeJumpTableInfo( |
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.
Looks like formatting unrelated to this patch occurred?
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.
addressed
raw_string_ostream StrOS(YamlMFI.RestorePoint.Value); | ||
StrOS << printMBBReference(*MFI.getRestorePoint()); | ||
} | ||
if (MFI.getSavePoint()) |
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.
Here we have singular getSavePoint, plural YamlMFI.SavePoints, and singular getSavePoint again. It is a little weird that we're mixing singular and plural.
This makes me think that we should get rid of SavePoint and RestorePoint and replace it entirely with the plural SavePoints and RestorePoints. By this I mean SavePoint
and RestorePoint
should be replaced entirely in MIR with SavePoints
and RestorePoints
. There plural version can do everything the singular version can and more.
This could be done in a follow up patch if others agree this would be a good direction to move in.
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.
I can do it it the follow up patch.
Shrink-Wrap points split Part 2. RFC: https://discourse.llvm.org/t/shrink-wrap-save-restore-points-splitting/83581 Part 1: #117862 Part 3: #119357 Part 4: #119358 Part 5: #119359
…355) Shrink-Wrap points split Part 2. RFC: https://discourse.llvm.org/t/shrink-wrap-save-restore-points-splitting/83581 Part 1: llvm/llvm-project#117862 Part 3: llvm/llvm-project#119357 Part 4: llvm/llvm-project#119358 Part 5: llvm/llvm-project#119359
I think this patch is due for a rebase :) |
Reverse ping! |
@michaelmaitland, I was on long vacations. This week I plan to return to work on this MR:) |
Lovely, I hope you had a wonderful vacation! Excited to give review and drive this forward. |
08ad616
to
37c305d
Compare
✅ With the latest revision this PR passed the C/C++ code formatter. |
37c305d
to
1daee32
Compare
Currently mir supports only one save and one restore point specification: ``` savePoint: '%bb.1' restorePoint: '%bb.2' ``` This patch provide possibility to specify multiple save and multiple restore points in mir: ``` savePoint: - point: '%bb.1' restorePoint: - point: '%bb.2' ``` while maintaining backward compatibility.
1daee32
to
baaea8d
Compare
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.
Should we have a test that shows multiple save points and multiple restore points?
@michaelmaitland, now multiple save and restore points are not supported in shrink-wrap. This patch only support possibility to print them in MIR. Real multiple save/restore points can appear only in #119359. |
Currently mir supports only one save and one restore point specification:
This patch provide possibility to have multiple save and multiple restore points in mir:
Shrink-Wrap points split Part 3.
RFC: https://discourse.llvm.org/t/shrink-wrap-save-restore-points-splitting/83581
Part 1: #117862
Part 2: #119355
Part 4: #119358
Part 5: #119359