[llvm] 9c12253 - MIR: Serialize FunctionContextIdx in MachineFrameInfo
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 22 08:07:46 PDT 2022
Author: Matt Arsenault
Date: 2022-04-22T11:07:41-04:00
New Revision: 9c122537cd7142e87799d9b99876ac04704c3308
URL: https://github.com/llvm/llvm-project/commit/9c122537cd7142e87799d9b99876ac04704c3308
DIFF: https://github.com/llvm/llvm-project/commit/9c122537cd7142e87799d9b99876ac04704c3308.diff
LOG: MIR: Serialize FunctionContextIdx in MachineFrameInfo
Added:
llvm/test/CodeGen/MIR/X86/expected-stack-object-function-context.mir
Modified:
llvm/include/llvm/CodeGen/MIRYamlMapping.h
llvm/lib/CodeGen/MIRParser/MIRParser.cpp
llvm/lib/CodeGen/MIRPrinter.cpp
llvm/test/CodeGen/MIR/Generic/frame-info.mir
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/MIRYamlMapping.h b/llvm/include/llvm/CodeGen/MIRYamlMapping.h
index 94198628518ac..25247437b6418 100644
--- a/llvm/include/llvm/CodeGen/MIRYamlMapping.h
+++ b/llvm/include/llvm/CodeGen/MIRYamlMapping.h
@@ -605,7 +605,7 @@ struct MachineFrameInfo {
bool AdjustsStack = false;
bool HasCalls = false;
StringValue StackProtector;
- // TODO: Serialize FunctionContextIdx
+ StringValue FunctionContext;
unsigned MaxCallFrameSize = ~0u; ///< ~0u means: not computed yet.
unsigned CVBytesOfCalleeSavedRegisters = 0;
bool HasOpaqueSPAdjustment = false;
@@ -626,6 +626,7 @@ struct MachineFrameInfo {
MaxAlignment == Other.MaxAlignment &&
AdjustsStack == Other.AdjustsStack && HasCalls == Other.HasCalls &&
StackProtector == Other.StackProtector &&
+ FunctionContext == Other.FunctionContext &&
MaxCallFrameSize == Other.MaxCallFrameSize &&
CVBytesOfCalleeSavedRegisters ==
Other.CVBytesOfCalleeSavedRegisters &&
@@ -651,6 +652,8 @@ template <> struct MappingTraits<MachineFrameInfo> {
YamlIO.mapOptional("hasCalls", MFI.HasCalls, false);
YamlIO.mapOptional("stackProtector", MFI.StackProtector,
StringValue()); // Don't print it out when it's empty.
+ YamlIO.mapOptional("functionContext", MFI.FunctionContext,
+ StringValue()); // Don't print it out when it's empty.
YamlIO.mapOptional("maxCallFrameSize", MFI.MaxCallFrameSize, (unsigned)~0);
YamlIO.mapOptional("cvBytesOfCalleeSavedRegisters",
MFI.CVBytesOfCalleeSavedRegisters, 0U);
diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
index 3f1b194358c27..88eb76090cf45 100644
--- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
@@ -831,6 +831,15 @@ bool MIRParserImpl::initializeFrameInfo(PerFunctionMIParsingState &PFS,
return error(Error, YamlMFI.StackProtector.SourceRange);
MFI.setStackProtectorIndex(FI);
}
+
+ if (!YamlMFI.FunctionContext.Value.empty()) {
+ SMDiagnostic Error;
+ int FI;
+ if (parseStackObjectReference(PFS, FI, YamlMFI.FunctionContext.Value, Error))
+ return error(Error, YamlMFI.FunctionContext.SourceRange);
+ MFI.setFunctionContextIndex(FI);
+ }
+
return false;
}
diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp
index 2fa4c45abe91f..8080b600789f6 100644
--- a/llvm/lib/CodeGen/MIRPrinter.cpp
+++ b/llvm/lib/CodeGen/MIRPrinter.cpp
@@ -481,6 +481,12 @@ void MIRPrinter::convertStackObjects(yaml::MachineFunction &YMF,
.printStackObjectReference(MFI.getStackProtectorIndex());
}
+ if (MFI.hasFunctionContextIndex()) {
+ raw_string_ostream StrOS(YMF.FrameInfo.FunctionContext.Value);
+ MIPrinter(StrOS, MST, RegisterMaskIds, StackObjectOperandMapping)
+ .printStackObjectReference(MFI.getFunctionContextIndex());
+ }
+
// Print the debug variable information.
for (const MachineFunction::VariableDbgInfo &DebugVar :
MF.getVariableDbgInfo()) {
diff --git a/llvm/test/CodeGen/MIR/Generic/frame-info.mir b/llvm/test/CodeGen/MIR/Generic/frame-info.mir
index 8fd9362e6db4a..c666482219e89 100644
--- a/llvm/test/CodeGen/MIR/Generic/frame-info.mir
+++ b/llvm/test/CodeGen/MIR/Generic/frame-info.mir
@@ -37,6 +37,7 @@ tracksRegLiveness: true
# CHECK-NEXT: adjustsStack: false
# CHECK-NEXT: hasCalls: false
# CHECK-NEXT: stackProtector: ''
+# CHECK-NEXT: functionContext: ''
# CHECK-NEXT: maxCallFrameSize:
# CHECK-NEXT: cvBytesOfCalleeSavedRegisters: 0
# CHECK-NEXT: hasOpaqueSPAdjustment: false
@@ -55,6 +56,8 @@ body: |
---
name: test2
tracksRegLiveness: true
+stack:
+ - { id: 0, offset: -40, size: 8, alignment: 8 }
# CHECK: test2
# CHECK: frameInfo:
@@ -69,6 +72,7 @@ tracksRegLiveness: true
# CHECK-NEXT: adjustsStack: true
# CHECK-NEXT: hasCalls: true
# CHECK-NEXT: stackProtector: ''
+# CHECK-NEXT: functionContext: '%stack.0'
# CHECK-NEXT: maxCallFrameSize: 4
# CHECK-NEXT: cvBytesOfCalleeSavedRegisters: 8
# CHECK-NEXT: hasOpaqueSPAdjustment: true
@@ -86,6 +90,7 @@ frameInfo:
maxAlignment: 4
adjustsStack: true
hasCalls: true
+ functionContext: '%stack.0'
maxCallFrameSize: 4
cvBytesOfCalleeSavedRegisters: 8
hasOpaqueSPAdjustment: true
diff --git a/llvm/test/CodeGen/MIR/X86/expected-stack-object-function-context.mir b/llvm/test/CodeGen/MIR/X86/expected-stack-object-function-context.mir
new file mode 100644
index 0000000000000..59d77b32f7fb7
--- /dev/null
+++ b/llvm/test/CodeGen/MIR/X86/expected-stack-object-function-context.mir
@@ -0,0 +1,13 @@
+# RUN: not llc -march=x86-64 -run-pass=none -o /dev/null %s 2>&1 | FileCheck %s
+
+---
+name: test
+frameInfo:
+ # CHECK: [[@LINE+1]]:22: expected a stack object
+ functionContext: '0'
+stack:
+ - { id: 0, offset: -24, size: 8, alignment: 8 }
+body: |
+ bb.0:
+
+...
More information about the llvm-commits
mailing list