1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[DEBUGINFO, NVPTX] Emit correct debug information for local variables.

Summary:
NVPTX target dos not use register-based frame information. Instead it
relies on the artificial local_depot that is used instead of the frame
and the data for variables must be emitted relatively to this
local_depot.

Reviewers: tra, jlebar, echristo

Subscribers: jholewinski, aprantl, JDevlieghere, llvm-commits

Differential Revision: https://reviews.llvm.org/D45963

llvm-svn: 338039
This commit is contained in:
Alexey Bataev 2018-07-26 16:29:52 +00:00
parent 3fed9b6e65
commit 7995e1a221
7 changed files with 40 additions and 13 deletions

View File

@ -201,6 +201,10 @@ public:
/// Return a unique ID for the current function.
unsigned getFunctionNumber() const;
/// Return symbol for the function pseudo stack if the stack frame is not a
/// register based.
virtual const MCSymbol *getFunctionFrameSymbol() const { return nullptr; }
MCSymbol *getFunctionBegin() const { return CurrentFnBegin; }
MCSymbol *getFunctionEnd() const { return CurrentFnEnd; }
MCSymbol *getCurExceptionSym();

View File

@ -578,8 +578,11 @@ DIE *DwarfCompileUnit::constructVariableDIEImpl(const DbgVariable &DV,
Ops.append(Expr->elements_begin(), Expr->elements_end());
DIExpressionCursor Cursor(Ops);
DwarfExpr.setMemoryLocationKind();
DwarfExpr.addMachineRegExpression(
*Asm->MF->getSubtarget().getRegisterInfo(), Cursor, FrameReg);
if (const MCSymbol *FrameSymbol = Asm->getFunctionFrameSymbol())
addOpAddress(*Loc, FrameSymbol);
else
DwarfExpr.addMachineRegExpression(
*Asm->MF->getSubtarget().getRegisterInfo(), Cursor, FrameReg);
DwarfExpr.addExpression(std::move(Cursor));
}
addBlock(*VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());

View File

@ -495,6 +495,12 @@ void NVPTXAsmPrinter::EmitFunctionBodyEnd() {
VRegMapping.clear();
}
const MCSymbol *NVPTXAsmPrinter::getFunctionFrameSymbol() const {
SmallString<128> Str;
raw_svector_ostream(Str) << DEPOTNAME << getFunctionNumber();
return OutContext.getOrCreateSymbol(Str);
}
void NVPTXAsmPrinter::emitImplicitDef(const MachineInstr *MI) const {
unsigned RegNo = MI->getOperand(0).getReg();
if (TargetRegisterInfo::isVirtualRegister(RegNo)) {

View File

@ -310,6 +310,8 @@ public:
}
std::string getVirtualRegisterName(unsigned) const;
const MCSymbol *getFunctionFrameSymbol() const override;
};
} // end namespace llvm

View File

@ -64,6 +64,14 @@ void NVPTXFrameLowering::emitPrologue(MachineFunction &MF,
}
}
int NVPTXFrameLowering::getFrameIndexReference(const MachineFunction &MF,
int FI,
unsigned &FrameReg) const {
const MachineFrameInfo &MFI = MF.getFrameInfo();
FrameReg = NVPTX::VRDepot;
return MFI.getObjectOffset(FI) - getOffsetOfLocalArea();
}
void NVPTXFrameLowering::emitEpilogue(MachineFunction &MF,
MachineBasicBlock &MBB) const {}

View File

@ -25,6 +25,8 @@ public:
bool hasFP(const MachineFunction &MF) const override;
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
int getFrameIndexReference(const MachineFunction &MF, int FI,
unsigned &FrameReg) const override;
MachineBasicBlock::iterator
eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,

View File

@ -123,12 +123,12 @@
; CHECK: // }
; CHECK: // .section .debug_info
; CHECK: // {
; CHECK: // .b32 126 // Length of Unit
; CHECK: // .b32 135 // Length of Unit
; CHECK: // .b8 2 // DWARF version number
; CHECK: // .b8 0
; CHECK: // .b32 .debug_abbrev // Offset Into Abbrev. Section
; CHECK: // .b8 8 // Address Size (in bytes)
; CHECK: // .b8 1 // Abbrev [1] 0xb:0x77 DW_TAG_compile_unit
; CHECK: // .b8 1 // Abbrev [1] 0xb:0x80 DW_TAG_compile_unit
; CHECK: // .b8 99 // DW_AT_producer
; CHECK: // .b8 108
; CHECK: // .b8 97
@ -149,7 +149,7 @@
; CHECK: // .b8 0
; CHECK: // .b64 Lfunc_begin0 // DW_AT_low_pc
; CHECK: // .b64 Lfunc_end0 // DW_AT_high_pc
; CHECK: // .b8 2 // Abbrev [2] 0x31:0x34 DW_TAG_subprogram
; CHECK: // .b8 2 // Abbrev [2] 0x31:0x3d DW_TAG_subprogram
; CHECK: // .b64 Lfunc_begin0 // DW_AT_low_pc
; CHECK: // .b64 Lfunc_end0 // DW_AT_high_pc
; CHECK: // .b8 1 // DW_AT_frame_base
@ -174,17 +174,19 @@
; CHECK: // .b8 3 // DW_AT_decl_line
; CHECK: // .b8 1 // DW_AT_prototyped
; CHECK: // .b8 1 // DW_AT_external
; CHECK: // .b8 3 // Abbrev [3] 0x58:0xc DW_TAG_variable
; CHECK: // .b8 2 // DW_AT_location
; CHECK: // .b8 3 // Abbrev [3] 0x58:0x15 DW_TAG_variable
; CHECK: // .b8 11 // DW_AT_location
; CHECK: // .b8 3
; CHECK: // .b64 __local_depot0
; CHECK: // .b8 35
; CHECK: // .b8 8
; CHECK: // .b8 0
; CHECK: // .b8 111 // DW_AT_name
; CHECK: // .b8 0
; CHECK: // .b8 1 // DW_AT_decl_file
; CHECK: // .b8 4 // DW_AT_decl_line
; CHECK: // .b32 101 // DW_AT_type
; CHECK: // .b32 110 // DW_AT_type
; CHECK: // .b8 0 // End Of Children Mark
; CHECK: // .b8 4 // Abbrev [4] 0x65:0x15 DW_TAG_structure_type
; CHECK: // .b8 4 // Abbrev [4] 0x6e:0x15 DW_TAG_structure_type
; CHECK: // .b8 70 // DW_AT_name
; CHECK: // .b8 111
; CHECK: // .b8 111
@ -192,17 +194,17 @@
; CHECK: // .b8 4 // DW_AT_byte_size
; CHECK: // .b8 1 // DW_AT_decl_file
; CHECK: // .b8 1 // DW_AT_decl_line
; CHECK: // .b8 5 // Abbrev [5] 0x6d:0xc DW_TAG_member
; CHECK: // .b8 5 // Abbrev [5] 0x76:0xc DW_TAG_member
; CHECK: // .b8 120 // DW_AT_name
; CHECK: // .b8 0
; CHECK: // .b32 122 // DW_AT_type
; CHECK: // .b32 131 // DW_AT_type
; CHECK: // .b8 1 // DW_AT_decl_file
; CHECK: // .b8 1 // DW_AT_decl_line
; CHECK: // .b8 2 // DW_AT_data_member_location
; CHECK: // .b8 35
; CHECK: // .b8 0
; CHECK: // .b8 0 // End Of Children Mark
; CHECK: // .b8 6 // Abbrev [6] 0x7a:0x7 DW_TAG_base_type
; CHECK: // .b8 6 // Abbrev [6] 0x83:0x7 DW_TAG_base_type
; CHECK: // .b8 105 // DW_AT_name
; CHECK: // .b8 110
; CHECK: // .b8 116