mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-12 03:32:10 +00:00
Refactor some common logic in DwarfUnit::constructVariableDIE and pass non-null DIE by reference to DbgVariable::setDIE
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207244 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
04f826c062
commit
7d772dda4e
@ -83,7 +83,7 @@ public:
|
||||
|
||||
// Accessors.
|
||||
DIVariable getVariable() const { return Var; }
|
||||
void setDIE(DIE *D) { TheDIE = D; }
|
||||
void setDIE(DIE &D) { TheDIE = &D; }
|
||||
DIE *getDIE() const { return TheDIE; }
|
||||
void setDotDebugLocOffset(unsigned O) { DotDebugLocOffset = O; }
|
||||
unsigned getDotDebugLocOffset() const { return DotDebugLocOffset; }
|
||||
|
@ -1802,6 +1802,13 @@ void DwarfUnit::constructContainingTypeDIEs() {
|
||||
|
||||
/// constructVariableDIE - Construct a DIE for the given DbgVariable.
|
||||
DIE *DwarfUnit::constructVariableDIE(DbgVariable &DV, bool isScopeAbstract) {
|
||||
auto D = constructVariableDIEImpl(DV, isScopeAbstract);
|
||||
DV.setDIE(*D);
|
||||
return D;
|
||||
}
|
||||
|
||||
DIE *DwarfUnit::constructVariableDIEImpl(const DbgVariable &DV,
|
||||
bool isScopeAbstract) {
|
||||
StringRef Name = DV.getName();
|
||||
|
||||
// Define variable debug information entry.
|
||||
@ -1820,17 +1827,14 @@ DIE *DwarfUnit::constructVariableDIE(DbgVariable &DV, bool isScopeAbstract) {
|
||||
if (DV.isArtificial())
|
||||
addFlag(VariableDie, dwarf::DW_AT_artificial);
|
||||
|
||||
if (isScopeAbstract) {
|
||||
DV.setDIE(VariableDie);
|
||||
if (isScopeAbstract)
|
||||
return VariableDie;
|
||||
}
|
||||
|
||||
// Add variable address.
|
||||
|
||||
unsigned Offset = DV.getDotDebugLocOffset();
|
||||
if (Offset != ~0U) {
|
||||
addLocationList(VariableDie, dwarf::DW_AT_location, Offset);
|
||||
DV.setDIE(VariableDie);
|
||||
return VariableDie;
|
||||
}
|
||||
|
||||
@ -1854,21 +1858,19 @@ DIE *DwarfUnit::constructVariableDIE(DbgVariable &DV, bool isScopeAbstract) {
|
||||
addConstantValue(VariableDie, DVInsn->getOperand(0).getCImm(),
|
||||
isUnsignedDIType(DD, DV.getType()));
|
||||
|
||||
DV.setDIE(VariableDie);
|
||||
return VariableDie;
|
||||
} else {
|
||||
// .. else use frame index.
|
||||
int FI = DV.getFrameIndex();
|
||||
if (FI != ~0) {
|
||||
unsigned FrameReg = 0;
|
||||
const TargetFrameLowering *TFI = Asm->TM.getFrameLowering();
|
||||
int Offset = TFI->getFrameIndexReference(*Asm->MF, FI, FrameReg);
|
||||
MachineLocation Location(FrameReg, Offset);
|
||||
addVariableAddress(DV, VariableDie, Location);
|
||||
}
|
||||
}
|
||||
|
||||
DV.setDIE(VariableDie);
|
||||
// .. else use frame index.
|
||||
int FI = DV.getFrameIndex();
|
||||
if (FI != ~0) {
|
||||
unsigned FrameReg = 0;
|
||||
const TargetFrameLowering *TFI = Asm->TM.getFrameLowering();
|
||||
int Offset = TFI->getFrameIndexReference(*Asm->MF, FI, FrameReg);
|
||||
MachineLocation Location(FrameReg, Offset);
|
||||
addVariableAddress(DV, VariableDie, Location);
|
||||
}
|
||||
|
||||
return VariableDie;
|
||||
}
|
||||
|
||||
|
@ -457,6 +457,10 @@ protected:
|
||||
virtual unsigned getOrCreateSourceID(StringRef File, StringRef Directory) = 0;
|
||||
|
||||
private:
|
||||
/// \brief Construct a DIE for the given DbgVariable without initializing the
|
||||
/// DbgVariable's DIE reference.
|
||||
DIE *constructVariableDIEImpl(const DbgVariable &DV, bool isScopeAbstract);
|
||||
|
||||
/// constructTypeDIE - Construct basic type die from DIBasicType.
|
||||
void constructTypeDIE(DIE &Buffer, DIBasicType BTy);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user