@@ -340,13 +340,24 @@ DIE &DwarfCompileUnit::updateSubprogramScopeDIE(const DISubprogram *SP) {
340
340
341
341
// Only include DW_AT_frame_base in full debug info
342
342
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) {
344
346
DIELoc *Loc = new (DIEValueAllocator) DIELoc;
345
347
addUInt (*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_call_frame_cfa);
346
348
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
+ }
347
358
} 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 );
350
361
if (RI->isPhysicalRegister (Location.getReg ()))
351
362
addAddress (*SPDie, dwarf::DW_AT_frame_base, Location);
352
363
}
@@ -1023,7 +1034,7 @@ void DwarfCompileUnit::addVariableAddress(const DbgVariable &DV, DIE &Die,
1023
1034
1024
1035
// / Add an address attribute to a die based on the location provided.
1025
1036
void DwarfCompileUnit::addAddress (DIE &Die, dwarf::Attribute Attribute,
1026
- const MachineLocation &Location) {
1037
+ const MachineLocation &Location) {
1027
1038
DIELoc *Loc = new (DIEValueAllocator) DIELoc;
1028
1039
DIEDwarfExpression DwarfExpr (*Asm, *this , *Loc);
1029
1040
if (Location.isIndirect ())
0 commit comments