aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2023-07-26 19:03:47 +0000
committerDimitry Andric <dim@FreeBSD.org>2023-07-26 19:04:23 +0000
commit7fa27ce4a07f19b07799a767fc29416f3b625afb (patch)
tree27825c83636c4de341eb09a74f49f5d38a15d165 /llvm/lib/CodeGen/MIRParser/MIRParser.cpp
parente3b557809604d036af6e00c60f012c2025b59a5e (diff)
Diffstat (limited to 'llvm/lib/CodeGen/MIRParser/MIRParser.cpp')
-rw-r--r--llvm/lib/CodeGen/MIRParser/MIRParser.cpp74
1 files changed, 57 insertions, 17 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
index a20c2bfe6c0f..b2e570c5e67e 100644
--- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
@@ -130,6 +130,16 @@ public:
const yaml::StringValue &RegisterSource,
bool IsRestored, int FrameIdx);
+ struct VarExprLoc {
+ DILocalVariable *DIVar = nullptr;
+ DIExpression *DIExpr = nullptr;
+ DILocation *DILoc = nullptr;
+ };
+
+ std::optional<VarExprLoc> parseVarExprLoc(PerFunctionMIParsingState &PFS,
+ const yaml::StringValue &VarStr,
+ const yaml::StringValue &ExprStr,
+ const yaml::StringValue &LocStr);
template <typename T>
bool parseStackObjectsDebugInfo(PerFunctionMIParsingState &PFS,
const T &Object,
@@ -392,7 +402,7 @@ bool MIRParserImpl::initializeCallSiteInfo(
MachineFunction &MF = PFS.MF;
SMDiagnostic Error;
const LLVMTargetMachine &TM = MF.getTarget();
- for (auto YamlCSInfo : YamlMF.CallSitesInfo) {
+ for (auto &YamlCSInfo : YamlMF.CallSitesInfo) {
yaml::CallSiteInfo::MachineInstrLoc MILoc = YamlCSInfo.CallLocation;
if (MILoc.BlockNum >= MF.size())
return error(Twine(MF.getName()) +
@@ -468,6 +478,7 @@ MIRParserImpl::initializeMachineFunction(const yaml::MachineFunction &YamlMF,
MF.setHasEHCatchret(YamlMF.HasEHCatchret);
MF.setHasEHScopes(YamlMF.HasEHScopes);
MF.setHasEHFunclets(YamlMF.HasEHFunclets);
+ MF.setIsOutlined(YamlMF.IsOutlined);
if (YamlMF.Legalized)
MF.getProperties().set(MachineFunctionProperties::Property::Legalized);
@@ -792,6 +803,24 @@ bool MIRParserImpl::initializeFrameInfo(PerFunctionMIParsingState &PFS,
return true;
}
+ for (const auto &Object : YamlMF.EntryValueObjects) {
+ SMDiagnostic Error;
+ Register Reg;
+ if (parseNamedRegisterReference(PFS, Reg, Object.EntryValueRegister.Value,
+ Error))
+ return error(Error, Object.EntryValueRegister.SourceRange);
+ if (!Reg.isPhysical())
+ return error(Object.EntryValueRegister.SourceRange.Start,
+ "Expected physical register for entry value field");
+ std::optional<VarExprLoc> MaybeInfo = parseVarExprLoc(
+ PFS, Object.DebugVar, Object.DebugExpr, Object.DebugLoc);
+ if (!MaybeInfo)
+ return true;
+ if (MaybeInfo->DIVar || MaybeInfo->DIExpr || MaybeInfo->DILoc)
+ PFS.MF.setVariableDbgInfo(MaybeInfo->DIVar, MaybeInfo->DIExpr,
+ Reg.asMCReg(), MaybeInfo->DILoc);
+ }
+
// Initialize the ordinary frame objects.
for (const auto &Object : YamlMF.StackObjects) {
int ObjectIdx;
@@ -887,26 +916,37 @@ static bool typecheckMDNode(T *&Result, MDNode *Node,
return false;
}
-template <typename T>
-bool MIRParserImpl::parseStackObjectsDebugInfo(PerFunctionMIParsingState &PFS,
- const T &Object, int FrameIdx) {
- // Debug information can only be attached to stack objects; Fixed stack
- // objects aren't supported.
- MDNode *Var = nullptr, *Expr = nullptr, *Loc = nullptr;
- if (parseMDNode(PFS, Var, Object.DebugVar) ||
- parseMDNode(PFS, Expr, Object.DebugExpr) ||
- parseMDNode(PFS, Loc, Object.DebugLoc))
- return true;
- if (!Var && !Expr && !Loc)
- return false;
+std::optional<MIRParserImpl::VarExprLoc> MIRParserImpl::parseVarExprLoc(
+ PerFunctionMIParsingState &PFS, const yaml::StringValue &VarStr,
+ const yaml::StringValue &ExprStr, const yaml::StringValue &LocStr) {
+ MDNode *Var = nullptr;
+ MDNode *Expr = nullptr;
+ MDNode *Loc = nullptr;
+ if (parseMDNode(PFS, Var, VarStr) || parseMDNode(PFS, Expr, ExprStr) ||
+ parseMDNode(PFS, Loc, LocStr))
+ return std::nullopt;
DILocalVariable *DIVar = nullptr;
DIExpression *DIExpr = nullptr;
DILocation *DILoc = nullptr;
- if (typecheckMDNode(DIVar, Var, Object.DebugVar, "DILocalVariable", *this) ||
- typecheckMDNode(DIExpr, Expr, Object.DebugExpr, "DIExpression", *this) ||
- typecheckMDNode(DILoc, Loc, Object.DebugLoc, "DILocation", *this))
+ if (typecheckMDNode(DIVar, Var, VarStr, "DILocalVariable", *this) ||
+ typecheckMDNode(DIExpr, Expr, ExprStr, "DIExpression", *this) ||
+ typecheckMDNode(DILoc, Loc, LocStr, "DILocation", *this))
+ return std::nullopt;
+ return VarExprLoc{DIVar, DIExpr, DILoc};
+}
+
+template <typename T>
+bool MIRParserImpl::parseStackObjectsDebugInfo(PerFunctionMIParsingState &PFS,
+ const T &Object, int FrameIdx) {
+ std::optional<VarExprLoc> MaybeInfo =
+ parseVarExprLoc(PFS, Object.DebugVar, Object.DebugExpr, Object.DebugLoc);
+ if (!MaybeInfo)
return true;
- PFS.MF.setVariableDbgInfo(DIVar, DIExpr, FrameIdx, DILoc);
+ // Debug information can only be attached to stack objects; Fixed stack
+ // objects aren't supported.
+ if (MaybeInfo->DIVar || MaybeInfo->DIExpr || MaybeInfo->DILoc)
+ PFS.MF.setVariableDbgInfo(MaybeInfo->DIVar, MaybeInfo->DIExpr, FrameIdx,
+ MaybeInfo->DILoc);
return false;
}