@@ -392,13 +392,24 @@ DIE &DwarfCompileUnit::updateSubprogramScopeDIE(const DISubprogram *SP) {
392392
393393 // Only include DW_AT_frame_base in full debug info
394394 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) {
396398 DIELoc *Loc = new (DIEValueAllocator) DIELoc;
397399 addUInt (*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_call_frame_cfa);
398400 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+ }
399410 } 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 );
402413 if (RI->isPhysicalRegister (Location.getReg ()))
403414 addAddress (*SPDie, dwarf::DW_AT_frame_base, Location);
404415 }
0 commit comments