@@ -392,13 +392,24 @@ DIE &DwarfCompileUnit::updateSubprogramScopeDIE(const DISubprogram *SP) {
392
392
393
393
// Only include DW_AT_frame_base in full debug info
394
394
if (!includeMinimalInlineScopes ()) {
395
- if (Asm->MF ->getTarget ().getTargetTriple ().isNVPTX ()) {
395
+ const TargetRegisterInfo *RI = Asm->MF ->getSubtarget ().getRegisterInfo ();
396
+ auto FBL = RI->getFrameBaseLocation (*Asm->MF );
397
+ if (FBL.Kind == FrameBaseLocation::CFA) {
396
398
DIELoc *Loc = new (DIEValueAllocator) DIELoc;
397
399
addUInt (*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_call_frame_cfa);
398
400
addBlock (*SPDie, dwarf::DW_AT_frame_base, Loc);
401
+ } else if (FBL.Kind == FrameBaseLocation::TargetIndex) {
402
+ if (FBL.TI .Offset >= 0 ) {
403
+ DIELoc *Loc = new (DIEValueAllocator) DIELoc;
404
+ DIEDwarfExpression DwarfExpr (*Asm, *this , *Loc);
405
+ DIExpressionCursor Cursor ({});
406
+ DwarfExpr.addTargetIndexLocation (FBL.TI .Index , FBL.TI .Offset );
407
+ DwarfExpr.addExpression (std::move (Cursor));
408
+ addBlock (*SPDie, dwarf::DW_AT_frame_base, DwarfExpr.finalize ());
409
+ }
399
410
} else {
400
- const TargetRegisterInfo *RI = Asm-> MF -> getSubtarget (). getRegisterInfo ( );
401
- MachineLocation Location (RI-> getFrameRegister (*Asm-> MF ) );
411
+ assert (FBL. Kind == FrameBaseLocation::Register );
412
+ MachineLocation Location (FBL. Reg );
402
413
if (RI->isPhysicalRegister (Location.getReg ()))
403
414
addAddress (*SPDie, dwarf::DW_AT_frame_base, Location);
404
415
}
0 commit comments