@@ -340,13 +340,24 @@ DIE &DwarfCompileUnit::updateSubprogramScopeDIE(const DISubprogram *SP) {
340340
341341 // Only include DW_AT_frame_base in full debug info
342342 if (!includeMinimalInlineScopes ()) {
343- if (Asm->MF ->getTarget ().getTargetTriple ().isNVPTX ()) {
343+ const TargetRegisterInfo *RI = Asm->MF ->getSubtarget ().getRegisterInfo ();
344+ auto FBL = RI->getFrameBaseLocation (*Asm->MF );
345+ if (FBL.Kind == FrameBaseLocation::CFA) {
344346 DIELoc *Loc = new (DIEValueAllocator) DIELoc;
345347 addUInt (*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_call_frame_cfa);
346348 addBlock (*SPDie, dwarf::DW_AT_frame_base, Loc);
349+ } else if (FBL.Kind == FrameBaseLocation::TargetIndex) {
350+ if (FBL.TI .Offset >= 0 ) {
351+ DIELoc *Loc = new (DIEValueAllocator) DIELoc;
352+ DIEDwarfExpression DwarfExpr (*Asm, *this , *Loc);
353+ DIExpressionCursor Cursor ({});
354+ DwarfExpr.addTargetIndexLocation (FBL.TI .Index , FBL.TI .Offset );
355+ DwarfExpr.addExpression (std::move (Cursor));
356+ addBlock (*SPDie, dwarf::DW_AT_frame_base, DwarfExpr.finalize ());
357+ }
347358 } else {
348- const TargetRegisterInfo *RI = Asm-> MF -> getSubtarget (). getRegisterInfo ( );
349- MachineLocation Location (RI-> getFrameRegister (*Asm-> MF ) );
359+ assert (FBL. Kind == FrameBaseLocation::Register );
360+ MachineLocation Location (FBL. Reg );
350361 if (RI->isPhysicalRegister (Location.getReg ()))
351362 addAddress (*SPDie, dwarf::DW_AT_frame_base, Location);
352363 }
@@ -1023,7 +1034,7 @@ void DwarfCompileUnit::addVariableAddress(const DbgVariable &DV, DIE &Die,
10231034
10241035// / Add an address attribute to a die based on the location provided.
10251036void DwarfCompileUnit::addAddress (DIE &Die, dwarf::Attribute Attribute,
1026- const MachineLocation &Location) {
1037+ const MachineLocation &Location) {
10271038 DIELoc *Loc = new (DIEValueAllocator) DIELoc;
10281039 DIEDwarfExpression DwarfExpr (*Asm, *this , *Loc);
10291040 if (Location.isIndirect ())
0 commit comments