Skip to content

Commit 4d629f9

Browse files
authored
[MIR] Remove std::variant from multiple save/restore point handling [nfc] (#153226)
In review of bbde6b, I had originally proposed that we support the legacy text format. As review evolved, it bacame clear this had been a bad idea (too much complexity), but in order to let that patch finally move forward, I approved the change with the variant. This change undoes the variant, and updates all the tests to just use the array form.
1 parent 9b93ccb commit 4d629f9

File tree

343 files changed

+1271
-1313
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

343 files changed

+1271
-1313
lines changed

llvm/include/llvm/CodeGen/MIRYamlMapping.h

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -644,38 +644,7 @@ struct SaveRestorePointEntry {
644644
}
645645
};
646646

647-
using SaveRestorePoints =
648-
std::variant<std::vector<SaveRestorePointEntry>, StringValue>;
649-
650-
template <> struct PolymorphicTraits<SaveRestorePoints> {
651-
652-
static NodeKind getKind(const SaveRestorePoints &SRPoints) {
653-
if (std::holds_alternative<std::vector<SaveRestorePointEntry>>(SRPoints))
654-
return NodeKind::Sequence;
655-
if (std::holds_alternative<StringValue>(SRPoints))
656-
return NodeKind::Scalar;
657-
llvm_unreachable("Unsupported NodeKind of SaveRestorePoints");
658-
}
659-
660-
static SaveRestorePointEntry &getAsMap(SaveRestorePoints &SRPoints) {
661-
llvm_unreachable("SaveRestorePoints can't be represented as Map");
662-
}
663-
664-
static std::vector<SaveRestorePointEntry> &
665-
getAsSequence(SaveRestorePoints &SRPoints) {
666-
if (!std::holds_alternative<std::vector<SaveRestorePointEntry>>(SRPoints))
667-
SRPoints = std::vector<SaveRestorePointEntry>();
668-
669-
return std::get<std::vector<SaveRestorePointEntry>>(SRPoints);
670-
}
671-
672-
static StringValue &getAsScalar(SaveRestorePoints &SRPoints) {
673-
if (!std::holds_alternative<StringValue>(SRPoints))
674-
SRPoints = StringValue();
675-
676-
return std::get<StringValue>(SRPoints);
677-
}
678-
};
647+
using SaveRestorePoints = std::vector<SaveRestorePointEntry>;
679648

680649
template <> struct MappingTraits<SaveRestorePointEntry> {
681650
static void mapping(IO &YamlIO, SaveRestorePointEntry &Entry) {
@@ -781,14 +750,8 @@ template <> struct MappingTraits<MachineFrameInfo> {
781750
YamlIO.mapOptional("isCalleeSavedInfoValid", MFI.IsCalleeSavedInfoValid,
782751
false);
783752
YamlIO.mapOptional("localFrameSize", MFI.LocalFrameSize, (unsigned)0);
784-
YamlIO.mapOptional(
785-
"savePoint", MFI.SavePoints,
786-
SaveRestorePoints(
787-
StringValue())); // Don't print it out when it's empty.
788-
YamlIO.mapOptional(
789-
"restorePoint", MFI.RestorePoints,
790-
SaveRestorePoints(
791-
StringValue())); // Don't print it out when it's empty.
753+
YamlIO.mapOptional("savePoint", MFI.SavePoints);
754+
YamlIO.mapOptional("restorePoint", MFI.RestorePoints);
792755
}
793756
};
794757

llvm/lib/CodeGen/MIRParser/MIRParser.cpp

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,23 +1099,8 @@ bool MIRParserImpl::initializeSaveRestorePoints(
10991099
PerFunctionMIParsingState &PFS, const yaml::SaveRestorePoints &YamlSRPoints,
11001100
SmallVectorImpl<MachineBasicBlock *> &SaveRestorePoints) {
11011101
MachineBasicBlock *MBB = nullptr;
1102-
if (std::holds_alternative<std::vector<yaml::SaveRestorePointEntry>>(
1103-
YamlSRPoints)) {
1104-
const auto &VectorRepr =
1105-
std::get<std::vector<yaml::SaveRestorePointEntry>>(YamlSRPoints);
1106-
if (VectorRepr.empty())
1107-
return false;
1108-
for (const yaml::SaveRestorePointEntry &Entry : VectorRepr) {
1109-
const yaml::StringValue &MBBSource = Entry.Point;
1110-
if (parseMBBReference(PFS, MBB, MBBSource.Value))
1111-
return true;
1112-
SaveRestorePoints.push_back(MBB);
1113-
}
1114-
} else {
1115-
yaml::StringValue StringRepr = std::get<yaml::StringValue>(YamlSRPoints);
1116-
if (StringRepr.Value.empty())
1117-
return false;
1118-
if (parseMBBReference(PFS, MBB, StringRepr))
1102+
for (const yaml::SaveRestorePointEntry &Entry : YamlSRPoints) {
1103+
if (parseMBBReference(PFS, MBB, Entry.Point.Value))
11191104
return true;
11201105
SaveRestorePoints.push_back(MBB);
11211106
}

llvm/lib/CodeGen/MIRPrinter.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -618,16 +618,14 @@ static void convertMCP(yaml::MachineFunction &MF,
618618
static void convertSRPoints(ModuleSlotTracker &MST,
619619
yaml::SaveRestorePoints &YamlSRPoints,
620620
ArrayRef<MachineBasicBlock *> SRPoints) {
621-
auto &Points =
622-
std::get<std::vector<yaml::SaveRestorePointEntry>>(YamlSRPoints);
623621
for (const auto &MBB : SRPoints) {
624622
SmallString<16> Str;
625623
yaml::SaveRestorePointEntry Entry;
626624
raw_svector_ostream StrOS(Str);
627625
StrOS << printMBBReference(*MBB);
628626
Entry.Point = StrOS.str().str();
629627
Str.clear();
630-
Points.push_back(Entry);
628+
YamlSRPoints.push_back(Entry);
631629
}
632630
}
633631

llvm/test/CodeGen/AArch64/GlobalISel/store-merging-debug.mir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ frameInfo:
8686
hasMustTailInVarArgFunc: false
8787
hasTailCall: false
8888
localFrameSize: 0
89-
savePoint: ''
90-
restorePoint: ''
89+
savePoint: []
90+
restorePoint: []
9191
fixedStack: []
9292
stack: []
9393
callSites: []

llvm/test/CodeGen/AArch64/aarch64-ldst-no-premature-sp-pop.mir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ frameInfo:
5959
hasVAStart: false
6060
hasMustTailInVarArgFunc: false
6161
localFrameSize: 16
62-
savePoint: ''
63-
restorePoint: ''
62+
savePoint: []
63+
restorePoint: []
6464
fixedStack: []
6565
stack:
6666
- { id: 0, type: default, offset: -16, size: 16,

llvm/test/CodeGen/AArch64/aarch64-mov-debug-locs.mir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ frameInfo:
157157
hasVAStart: false
158158
hasMustTailInVarArgFunc: false
159159
localFrameSize: 0
160-
savePoint: ''
161-
restorePoint: ''
160+
savePoint: []
161+
restorePoint: []
162162
fixedStack: []
163163
stack:
164164
- { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8,

llvm/test/CodeGen/AArch64/aarch64st1.mir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ frameInfo:
5858
hasMustTailInVarArgFunc: false
5959
hasTailCall: false
6060
localFrameSize: 0
61-
savePoint: ''
62-
restorePoint: ''
61+
savePoint: []
62+
restorePoint: []
6363
fixedStack: []
6464
stack:
6565
- { id: 0, name: '', type: default, offset: 0, size: 4, alignment: 4,

llvm/test/CodeGen/AArch64/cfi-fixup-multi-block-prologue.mir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ frameInfo:
8080
hasMustTailInVarArgFunc: false
8181
hasTailCall: false
8282
localFrameSize: 30000
83-
savePoint: ''
84-
restorePoint: ''
83+
savePoint: []
84+
restorePoint: []
8585
fixedStack: []
8686
stack:
8787
- { id: 0, name: p, type: default, offset: -30016, size: 30000, alignment: 1,

llvm/test/CodeGen/AArch64/cfi-fixup-multi-section.mir

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ frameInfo:
5757
hasMustTailInVarArgFunc: false
5858
hasTailCall: false
5959
localFrameSize: 0
60-
savePoint: ''
61-
restorePoint: ''
60+
savePoint: []
61+
restorePoint: []
6262
fixedStack: []
6363
stack:
6464
- { id: 0, name: '', type: spill-slot, offset: -16, size: 8, alignment: 16,
@@ -240,8 +240,8 @@ frameInfo:
240240
hasMustTailInVarArgFunc: false
241241
hasTailCall: false
242242
localFrameSize: 0
243-
savePoint: ''
244-
restorePoint: ''
243+
savePoint: []
244+
restorePoint: []
245245
fixedStack: []
246246
stack:
247247
- { id: 0, name: '', type: spill-slot, offset: -16, size: 8, alignment: 16,

llvm/test/CodeGen/AArch64/cfi-fixup.mir

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ frameInfo:
6565
hasMustTailInVarArgFunc: false
6666
hasTailCall: false
6767
localFrameSize: 0
68-
savePoint: ''
69-
restorePoint: ''
68+
savePoint: []
69+
restorePoint: []
7070
fixedStack: []
7171
stack:
7272
- { id: 0, name: '', type: spill-slot, offset: -16, size: 8, alignment: 16,
@@ -248,8 +248,8 @@ frameInfo:
248248
hasMustTailInVarArgFunc: false
249249
hasTailCall: false
250250
localFrameSize: 0
251-
savePoint: ''
252-
restorePoint: ''
251+
savePoint: []
252+
restorePoint: []
253253
fixedStack: []
254254
stack:
255255
- { id: 0, name: '', type: spill-slot, offset: -16, size: 8, alignment: 16,
@@ -403,8 +403,8 @@ frameInfo:
403403
hasMustTailInVarArgFunc: false
404404
hasTailCall: false
405405
localFrameSize: 0
406-
savePoint: ''
407-
restorePoint: ''
406+
savePoint: []
407+
restorePoint: []
408408
fixedStack: []
409409
stack:
410410
- { id: 0, name: '', type: spill-slot, offset: -16, size: 8, alignment: 16,

0 commit comments

Comments
 (0)