diff options
author | Felipe de Azevedo Piovezan <fpiovezan@apple.com> | 2023-05-02 14:05:04 -0400 |
---|---|---|
committer | Felipe de Azevedo Piovezan <fpiovezan@apple.com> | 2023-05-12 12:00:13 -0400 |
commit | 2da29955fbc9753e7f0d565d64cc859492ab6afb (patch) | |
tree | b21fc40aa7919788e7a607b209d8d11a2440fc40 /llvm/lib | |
parent | 53a4adc0deb29fcc1f907ea7bc151fdebecf406d (diff) | |
download | llvm-2da29955fbc9753e7f0d565d64cc859492ab6afb.zip llvm-2da29955fbc9753e7f0d565d64cc859492ab6afb.tar.gz llvm-2da29955fbc9753e7f0d565d64cc859492ab6afb.tar.bz2 |
[SelectionDAG][DebugInfo] Implement translation of entry_value vars
This commit implements SelectionDAG lowering of dbg.declare intrinsics targeting
swiftasync Arguments, by putting them in the MachineFunction's table of
variables whose location doesn't change throughout the function.
Depends on D149882
Differential Revision: https://reviews.llvm.org/D149883
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 36611b1..35abd99 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -1342,6 +1342,30 @@ static bool isFoldedOrDeadInstruction(const Instruction *I, !FuncInfo.isExportedInst(I); // Exported instrs must be computed. } +static bool processIfEntryValueDbgDeclare(FunctionLoweringInfo &FuncInfo, + const Value *Arg, DIExpression *Expr, + DILocalVariable *Var, + DebugLoc DbgLoc) { + if (!Expr->isEntryValue() || !isa<Argument>(Arg)) + return false; + + auto ArgIt = FuncInfo.ValueMap.find(Arg); + if (ArgIt == FuncInfo.ValueMap.end()) + return false; + Register ArgVReg = ArgIt->getSecond(); + + // Find the corresponding livein physical register to this argument. + for (auto [PhysReg, VirtReg] : FuncInfo.RegInfo->liveins()) + if (VirtReg == ArgVReg) { + FuncInfo.MF->setVariableDbgInfo(Var, Expr, PhysReg, DbgLoc); + LLVM_DEBUG(dbgs() << "processDbgDeclare: setVariableDbgInfo Var=" << *Var + << ", Expr=" << *Expr << ", MCRegister=" << PhysReg + << ", DbgLoc=" << DbgLoc << "\n"); + return true; + } + return false; +} + static bool processDbgDeclare(FunctionLoweringInfo &FuncInfo, const Value *Address, DIExpression *Expr, DILocalVariable *Var, DebugLoc DbgLoc) { @@ -1350,6 +1374,10 @@ static bool processDbgDeclare(FunctionLoweringInfo &FuncInfo, << " (bad address)\n"); return false; } + + if (processIfEntryValueDbgDeclare(FuncInfo, Address, Expr, Var, DbgLoc)) + return true; + MachineFunction *MF = FuncInfo.MF; const DataLayout &DL = MF->getDataLayout(); |