mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-21 03:05:26 -04:00
[DebugInfo] Avoid crash from dropped fragments in LiveDebugValues
This patch avoids a crash caused by DW_OP_LLVM_fragments being dropped from DIExpressions by LiveDebugValues spill-restore code. The appearance of a previously unseen fragment configuration confuses LDV, as documented in PR42773, and reproduced by the test function this patch adds (Crashes on a x86_64 debug build). To avoid this, on spill restore, we now use fragment information from the spilt-location-expression. In addition, when spilling, we now don't spill any DBG_VALUE with a complex expression, as it can't be safely restored and will definitely lead to an incorrect variable location. The discussion of this is in D65368. Differential Revision: https://reviews.llvm.org/D66284 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369026 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -691,9 +691,17 @@ void LiveDebugValues::insertTransferDebugPair(
|
||||
"No register supplied when handling a restore of a debug value");
|
||||
MachineFunction *MF = MI.getMF();
|
||||
DIBuilder DIB(*const_cast<Function &>(MF->getFunction()).getParent());
|
||||
|
||||
const DIExpression *NewExpr;
|
||||
if (auto Fragment = DebugInstr->getDebugExpression()->getFragmentInfo())
|
||||
NewExpr = *DIExpression::createFragmentExpression(DIB.createExpression(),
|
||||
Fragment->OffsetInBits, Fragment->SizeInBits);
|
||||
else
|
||||
NewExpr = DIB.createExpression();
|
||||
|
||||
NewDebugInstr =
|
||||
BuildMI(*MF, DebugInstr->getDebugLoc(), DebugInstr->getDesc(), false,
|
||||
NewReg, DebugInstr->getDebugVariable(), DIB.createExpression());
|
||||
NewReg, DebugInstr->getDebugVariable(), NewExpr);
|
||||
VarLoc VL(*NewDebugInstr, LS);
|
||||
ProcessVarLoc(VL, NewDebugInstr);
|
||||
LLVM_DEBUG(dbgs() << "Creating DBG_VALUE inst for register restore: ";
|
||||
@@ -848,9 +856,14 @@ void LiveDebugValues::transferSpillOrRestoreInst(MachineInstr &MI,
|
||||
<< "\n");
|
||||
}
|
||||
// Check if the register or spill location is the location of a debug value.
|
||||
// FIXME: Don't create a spill transfer if there is a complex expression,
|
||||
// because we currently cannot recover the original expression on restore.
|
||||
for (unsigned ID : OpenRanges.getVarLocs()) {
|
||||
const MachineInstr *DebugInstr = &VarLocIDs[ID].MI;
|
||||
|
||||
if (TKind == TransferKind::TransferSpill &&
|
||||
VarLocIDs[ID].isDescribedByReg() == Reg) {
|
||||
VarLocIDs[ID].isDescribedByReg() == Reg &&
|
||||
!DebugInstr->getDebugExpression()->isComplex()) {
|
||||
LLVM_DEBUG(dbgs() << "Spilling Register " << printReg(Reg, TRI) << '('
|
||||
<< VarLocIDs[ID].Var.getVar()->getName() << ")\n");
|
||||
} else if (TKind == TransferKind::TransferRestore &&
|
||||
|
||||
Reference in New Issue
Block a user