Skip to content

Commit cf2f32c

Browse files
authored
[MIR] Serialize MachineFrameInfo::isCalleeSavedInfoValid() (#90561)
In case of functions without a stack frame no "stack" field is serialized into MIR which leads to isCalleeSavedInfoValid being false when reading a MIR file back in. To fix this we should serialize MachineFrameInfo::isCalleeSavedInfoValid() into MIR.
1 parent 6c369cf commit cf2f32c

File tree

5 files changed

+49
-1
lines changed

5 files changed

+49
-1
lines changed

llvm/include/llvm/CodeGen/MIRYamlMapping.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,7 @@ struct MachineFrameInfo {
640640
bool HasVAStart = false;
641641
bool HasMustTailInVarArgFunc = false;
642642
bool HasTailCall = false;
643+
bool IsCalleeSavedInfoValid = false;
643644
unsigned LocalFrameSize = 0;
644645
StringValue SavePoint;
645646
StringValue RestorePoint;
@@ -663,7 +664,8 @@ struct MachineFrameInfo {
663664
HasMustTailInVarArgFunc == Other.HasMustTailInVarArgFunc &&
664665
HasTailCall == Other.HasTailCall &&
665666
LocalFrameSize == Other.LocalFrameSize &&
666-
SavePoint == Other.SavePoint && RestorePoint == Other.RestorePoint;
667+
SavePoint == Other.SavePoint && RestorePoint == Other.RestorePoint &&
668+
IsCalleeSavedInfoValid == Other.IsCalleeSavedInfoValid;
667669
}
668670
};
669671

@@ -691,6 +693,8 @@ template <> struct MappingTraits<MachineFrameInfo> {
691693
YamlIO.mapOptional("hasMustTailInVarArgFunc", MFI.HasMustTailInVarArgFunc,
692694
false);
693695
YamlIO.mapOptional("hasTailCall", MFI.HasTailCall, false);
696+
YamlIO.mapOptional("isCalleeSavedInfoValid", MFI.IsCalleeSavedInfoValid,
697+
false);
694698
YamlIO.mapOptional("localFrameSize", MFI.LocalFrameSize, (unsigned)0);
695699
YamlIO.mapOptional("savePoint", MFI.SavePoint,
696700
StringValue()); // Don't print it out when it's empty.

llvm/lib/CodeGen/MIRParser/MIRParser.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,7 @@ bool MIRParserImpl::initializeFrameInfo(PerFunctionMIParsingState &PFS,
779779
MFI.setHasVAStart(YamlMFI.HasVAStart);
780780
MFI.setHasMustTailInVarArgFunc(YamlMFI.HasMustTailInVarArgFunc);
781781
MFI.setHasTailCall(YamlMFI.HasTailCall);
782+
MFI.setCalleeSavedInfoValid(YamlMFI.IsCalleeSavedInfoValid);
782783
MFI.setLocalFrameSize(YamlMFI.LocalFrameSize);
783784
if (!YamlMFI.SavePoint.Value.empty()) {
784785
MachineBasicBlock *MBB = nullptr;

llvm/lib/CodeGen/MIRPrinter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ void MIRPrinter::convert(ModuleSlotTracker &MST,
368368
YamlMFI.HasVAStart = MFI.hasVAStart();
369369
YamlMFI.HasMustTailInVarArgFunc = MFI.hasMustTailInVarArgFunc();
370370
YamlMFI.HasTailCall = MFI.hasTailCall();
371+
YamlMFI.IsCalleeSavedInfoValid = MFI.isCalleeSavedInfoValid();
371372
YamlMFI.LocalFrameSize = MFI.getLocalFrameSize();
372373
if (MFI.getSavePoint()) {
373374
raw_string_ostream StrOS(YamlMFI.SavePoint.Value);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
# RUN: llc -run-pass=none -mtriple=aarch64-- -o - %s | FileCheck %s
3+
4+
---
5+
# CHECK-LABEL: name: no_stack_no_calleesavedinfo
6+
# CHECK: isCalleeSavedInfoValid: false
7+
name: no_stack_no_calleesavedinfo
8+
frameInfo:
9+
isCalleeSavedInfoValid: false
10+
stack: []
11+
12+
...
13+
---
14+
# CHECK-LABEL: name: no_stack_calleesavedinfo
15+
# CHECK: isCalleeSavedInfoValid: true
16+
name: no_stack_calleesavedinfo
17+
frameInfo:
18+
isCalleeSavedInfoValid: true
19+
stack: []
20+
21+
...
22+
---
23+
# CHECK-LABEL: name: stack_no_calleesavedinfo
24+
# CHECK: isCalleeSavedInfoValid: true
25+
name: stack_no_calleesavedinfo
26+
frameInfo:
27+
isCalleeSavedInfoValid: false
28+
stack:
29+
- { id: 0, type: spill-slot, offset: -8, size: 8, alignment: 8, callee-saved-register: '$lr' }
30+
31+
...
32+
---
33+
# CHECK-LABEL: name: stack_calleesavedinfo
34+
# CHECK: isCalleeSavedInfoValid: true
35+
name: stack_calleesavedinfo
36+
frameInfo:
37+
isCalleeSavedInfoValid: true
38+
stack:
39+
- { id: 0, type: spill-slot, offset: -8, size: 8, alignment: 8, callee-saved-register: '$lr' }
40+
41+
...

llvm/test/CodeGen/MIR/Generic/frame-info.mir

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ tracksRegLiveness: true
4444
# CHECK-NEXT: hasVAStart: false
4545
# CHECK-NEXT: hasMustTailInVarArgFunc: false
4646
# CHECK-NEXT: hasTailCall: false
47+
# CHECK-NEXT: isCalleeSavedInfoValid: false
4748
# CHECK-NEXT: localFrameSize: 0
4849
# CHECK-NEXT: savePoint: ''
4950
# CHECK-NEXT: restorePoint: ''

0 commit comments

Comments
 (0)