1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00

DebugInfo: Drop rest of DIDescriptor subclasses

Delete the remaining subclasses of (the already deleted) `DIDescriptor`.
Part of PR23080.

llvm-svn: 235404
This commit is contained in:
Duncan P. N. Exon Smith 2015-04-21 18:44:06 +00:00
parent 8c237b09f4
commit 8911bb4284
28 changed files with 124 additions and 287 deletions

View File

@ -88,10 +88,9 @@ LLVMMetadataRef LLVMDIBuilderCreateLocalVariable(
const char *Name, LLVMMetadataRef File, unsigned Line, LLVMMetadataRef Ty,
int AlwaysPreserve, unsigned Flags, unsigned ArgNo) {
DIBuilder *D = unwrap(Dref);
DIVariable V = D->createLocalVariable(
return wrap(D->createLocalVariable(
Tag, unwrap<MDScope>(Scope), Name, unwrap<MDFile>(File), Line,
unwrap<MDType>(Ty), AlwaysPreserve, Flags, ArgNo);
return wrap(V);
unwrap<MDType>(Ty), AlwaysPreserve, Flags, ArgNo));
}
LLVMMetadataRef LLVMDIBuilderCreateBasicType(LLVMDIBuilderRef Dref,
@ -182,8 +181,7 @@ LLVMMetadataRef LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef Dref,
LLVMMetadataRef LLVMDIBuilderGetOrCreateSubrange(LLVMDIBuilderRef Dref,
int64_t Lo, int64_t Count) {
DIBuilder *D = unwrap(Dref);
DISubrange S = D->getOrCreateSubrange(Lo, Count);
return wrap(S);
return wrap(D->getOrCreateSubrange(Lo, Count));
}
LLVMMetadataRef LLVMDIBuilderGetOrCreateArray(LLVMDIBuilderRef Dref,
@ -209,8 +207,7 @@ LLVMMetadataRef LLVMDIBuilderGetOrCreateTypeArray(LLVMDIBuilderRef Dref,
LLVMMetadataRef LLVMDIBuilderCreateExpression(LLVMDIBuilderRef Dref,
int64_t *Addr, size_t Length) {
DIBuilder *D = unwrap(Dref);
DIExpression Expr = D->createExpression(ArrayRef<int64_t>(Addr, Length));
return wrap(Expr);
return wrap(D->createExpression(ArrayRef<int64_t>(Addr, Length)));
}
LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(LLVMDIBuilderRef Dref,

View File

@ -246,14 +246,14 @@ public:
/// \brief Return the debug variable referenced by
/// this DBG_VALUE instruction.
DIVariable getDebugVariable() const {
const MDLocalVariable *getDebugVariable() const {
assert(isDebugValue() && "not a DBG_VALUE");
return cast<MDLocalVariable>(getOperand(2).getMetadata());
}
/// \brief Return the complex address expression referenced by
/// this DBG_VALUE instruction.
DIExpression getDebugExpression() const {
const MDExpression *getDebugExpression() const {
assert(isDebugValue() && "not a DBG_VALUE");
return cast<MDExpression>(getOperand(3).getMetadata());
}

View File

@ -176,7 +176,7 @@ public:
MI->addOperand(*MF, MachineOperand::CreateMetadata(MD));
assert((MI->isDebugValue() ? static_cast<bool>(MI->getDebugVariable())
: true) &&
"first MDNode argument of a DBG_VALUE not a DIVariable");
"first MDNode argument of a DBG_VALUE not a variable");
return *this;
}
@ -356,8 +356,8 @@ inline MachineInstrBuilder BuildMI(MachineFunction &MF, DebugLoc DL,
const MCInstrDesc &MCID, bool IsIndirect,
unsigned Reg, unsigned Offset,
const MDNode *Variable, const MDNode *Expr) {
assert(isa<MDLocalVariable>(Variable) && "not a DIVariable");
assert(cast<MDExpression>(Expr)->isValid() && "not a DIExpression");
assert(isa<MDLocalVariable>(Variable) && "not a variable");
assert(cast<MDExpression>(Expr)->isValid() && "not an expression");
assert(cast<MDLocalVariable>(Variable)->isValidLocationForIntrinsic(DL) &&
"Expected inlined-at fields to agree");
if (IsIndirect)
@ -385,8 +385,8 @@ inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
const MCInstrDesc &MCID, bool IsIndirect,
unsigned Reg, unsigned Offset,
const MDNode *Variable, const MDNode *Expr) {
assert(isa<MDLocalVariable>(Variable) && "not a DIVariable");
assert(cast<MDExpression>(Expr)->isValid() && "not a DIExpression");
assert(isa<MDLocalVariable>(Variable) && "not a variable");
assert(cast<MDExpression>(Expr)->isValid() && "not an expression");
MachineFunction &MF = *BB.getParent();
MachineInstr *MI =
BuildMI(MF, DL, MCID, IsIndirect, Reg, Offset, Variable, Expr);

View File

@ -46,167 +46,12 @@ class NamedMDNode;
class LLVMContext;
class raw_ostream;
class DIVariable;
class DIObjCProperty;
/// \brief Maps from type identifier to the actual MDNode.
typedef DenseMap<const MDString *, MDNode *> DITypeIdentifierMap;
#define DECLARE_SIMPLIFY_DESCRIPTOR(DESC) \
class DESC; \
template <> struct simplify_type<const DESC>; \
template <> struct simplify_type<DESC>;
DECLARE_SIMPLIFY_DESCRIPTOR(DISubrange)
DECLARE_SIMPLIFY_DESCRIPTOR(DIEnumerator)
DECLARE_SIMPLIFY_DESCRIPTOR(DITemplateTypeParameter)
DECLARE_SIMPLIFY_DESCRIPTOR(DITemplateValueParameter)
DECLARE_SIMPLIFY_DESCRIPTOR(DIGlobalVariable)
DECLARE_SIMPLIFY_DESCRIPTOR(DIVariable)
DECLARE_SIMPLIFY_DESCRIPTOR(DIExpression)
DECLARE_SIMPLIFY_DESCRIPTOR(DILocation)
DECLARE_SIMPLIFY_DESCRIPTOR(DIObjCProperty)
DECLARE_SIMPLIFY_DESCRIPTOR(DIImportedEntity)
#undef DECLARE_SIMPLIFY_DESCRIPTOR
typedef DebugNodeArray DIArray;
typedef MDTypeRefArray DITypeArray;
class DISubrange {
MDSubrange *N;
public:
DISubrange(const MDSubrange *N = nullptr) : N(const_cast<MDSubrange *>(N)) {}
operator MDSubrange *() const { return N; }
MDSubrange *operator->() const { return N; }
MDSubrange &operator*() const { return *N; }
};
class DIEnumerator {
MDEnumerator *N;
public:
DIEnumerator(const MDEnumerator *N = nullptr)
: N(const_cast<MDEnumerator *>(N)) {}
operator MDEnumerator *() const { return N; }
MDEnumerator *operator->() const { return N; }
MDEnumerator &operator*() const { return *N; }
};
class DITemplateTypeParameter {
MDTemplateTypeParameter *N;
public:
DITemplateTypeParameter(const MDTemplateTypeParameter *N = nullptr)
: N(const_cast<MDTemplateTypeParameter *>(N)) {}
operator MDTemplateTypeParameter *() const { return N; }
MDTemplateTypeParameter *operator->() const { return N; }
MDTemplateTypeParameter &operator*() const { return *N; }
};
class DITemplateValueParameter {
MDTemplateValueParameter *N;
public:
DITemplateValueParameter(const MDTemplateValueParameter *N = nullptr)
: N(const_cast<MDTemplateValueParameter *>(N)) {}
operator MDTemplateValueParameter *() const { return N; }
MDTemplateValueParameter *operator->() const { return N; }
MDTemplateValueParameter &operator*() const { return *N; }
};
class DIGlobalVariable {
MDGlobalVariable *N;
public:
DIGlobalVariable(const MDGlobalVariable *N = nullptr)
: N(const_cast<MDGlobalVariable *>(N)) {}
operator MDGlobalVariable *() const { return N; }
MDGlobalVariable *operator->() const { return N; }
MDGlobalVariable &operator*() const { return *N; }
};
class DIVariable {
MDLocalVariable *N;
public:
DIVariable(const MDLocalVariable *N = nullptr)
: N(const_cast<MDLocalVariable *>(N)) {}
operator MDLocalVariable *() const { return N; }
MDLocalVariable *operator->() const { return N; }
MDLocalVariable &operator*() const { return *N; }
};
class DIExpression {
MDExpression *N;
public:
DIExpression(const MDExpression *N = nullptr)
: N(const_cast<MDExpression *>(N)) {}
operator MDExpression *() const { return N; }
MDExpression *operator->() const { return N; }
MDExpression &operator*() const { return *N; }
};
class DILocation {
MDLocation *N;
public:
DILocation(const MDLocation *N = nullptr) : N(const_cast<MDLocation *>(N)) {}
operator MDLocation *() const { return N; }
MDLocation *operator->() const { return N; }
MDLocation &operator*() const { return *N; }
};
class DIObjCProperty {
MDObjCProperty *N;
public:
DIObjCProperty(const MDObjCProperty *N = nullptr)
: N(const_cast<MDObjCProperty *>(N)) {}
operator MDObjCProperty *() const { return N; }
MDObjCProperty *operator->() const { return N; }
MDObjCProperty &operator*() const { return *N; }
};
class DIImportedEntity {
MDImportedEntity *N;
public:
DIImportedEntity(const MDImportedEntity *N = nullptr)
: N(const_cast<MDImportedEntity *>(N)) {}
operator MDImportedEntity *() const { return N; }
MDImportedEntity *operator->() const { return N; }
MDImportedEntity &operator*() const { return *N; }
};
#define SIMPLIFY_DESCRIPTOR(DESC) \
template <> struct simplify_type<const DESC> { \
typedef Metadata *SimpleType; \
static SimpleType getSimplifiedValue(const DESC &DI) { return DI; } \
}; \
template <> struct simplify_type<DESC> : simplify_type<const DESC> {};
SIMPLIFY_DESCRIPTOR(DISubrange)
SIMPLIFY_DESCRIPTOR(DIEnumerator)
SIMPLIFY_DESCRIPTOR(DITemplateTypeParameter)
SIMPLIFY_DESCRIPTOR(DITemplateValueParameter)
SIMPLIFY_DESCRIPTOR(DIGlobalVariable)
SIMPLIFY_DESCRIPTOR(DIVariable)
SIMPLIFY_DESCRIPTOR(DIExpression)
SIMPLIFY_DESCRIPTOR(DILocation)
SIMPLIFY_DESCRIPTOR(DIObjCProperty)
SIMPLIFY_DESCRIPTOR(DIImportedEntity)
#undef SIMPLIFY_DESCRIPTOR
/// \brief Find subprogram that is enclosing this scope.
MDSubprogram *getDISubprogram(const MDNode *Scope);
@ -251,7 +96,7 @@ public:
void processDeclare(const Module &M, const DbgDeclareInst *DDI);
/// \brief Process DbgValueInst.
void processValue(const Module &M, const DbgValueInst *DVI);
/// \brief Process DILocation.
/// \brief Process debug info location.
void processLocation(const Module &M, const MDLocation *Loc);
/// \brief Clear all lists.

View File

@ -90,7 +90,7 @@ void ModuleDebugInfoPrinter::print(raw_ostream &O, const Module *M) const {
O << '\n';
}
for (DIGlobalVariable GV : Finder.global_variables()) {
for (const MDGlobalVariable *GV : Finder.global_variables()) {
O << "Global variable: " << GV->getName();
printFile(O, GV->getFilename(), GV->getDirectory(), GV->getLine());
if (!GV->getLinkageName().empty())

View File

@ -670,7 +670,7 @@ static bool emitDebugValueComment(const MachineInstr *MI, AsmPrinter &AP) {
raw_svector_ostream OS(Str);
OS << "DEBUG_VALUE: ";
DIVariable V = MI->getDebugVariable();
const MDLocalVariable *V = MI->getDebugVariable();
if (auto *SP = dyn_cast<MDSubprogram>(V->getScope())) {
StringRef Name = SP->getDisplayName();
if (!Name.empty())
@ -678,7 +678,7 @@ static bool emitDebugValueComment(const MachineInstr *MI, AsmPrinter &AP) {
}
OS << V->getName();
DIExpression Expr = MI->getDebugExpression();
const MDExpression *Expr = MI->getDebugExpression();
if (Expr->isBitPiece())
OS << " [bit_piece offset=" << Expr->getBitPieceOffset()
<< " size=" << Expr->getBitPieceSize() << "]";

View File

@ -204,7 +204,7 @@ void llvm::calculateDbgValueHistory(const MachineFunction *MF,
// Use the base variable (without any DW_OP_piece expressions)
// as index into History. The full variables including the
// piece expressions are attached to the MI.
MDLocalVariable *RawVar = MI.getDebugVariable();
const MDLocalVariable *RawVar = MI.getDebugVariable();
assert(RawVar->isValidLocationForIntrinsic(MI.getDebugLoc()) &&
"Expected inlined-at fields to agree");
InlinedVariable Var(RawVar, MI.getDebugLoc()->getInlinedAt());

View File

@ -72,7 +72,7 @@ public:
const ConstantInt *getConstantInt() const { return Constant.CIP; }
MachineLocation getLoc() const { return Loc; }
bool isBitPiece() const { return getExpression()->isBitPiece(); }
DIExpression getExpression() const { return Expression; }
const MDExpression *getExpression() const { return Expression; }
friend bool operator==(const Value &, const Value &);
friend bool operator<(const Value &, const Value &);
};
@ -94,9 +94,8 @@ public:
/// Return true if the merge was successful.
bool MergeValues(const DebugLocEntry &Next) {
if (Begin == Next.Begin) {
DIExpression Expr = cast_or_null<MDExpression>(Values[0].Expression);
DIExpression NextExpr =
cast_or_null<MDExpression>(Next.Values[0].Expression);
auto *Expr = cast_or_null<MDExpression>(Values[0].Expression);
auto *NextExpr = cast_or_null<MDExpression>(Next.Values[0].Expression);
if (Expr->isBitPiece() && NextExpr->isBitPiece()) {
addValues(Next.Values);
End = Next.End;

View File

@ -97,7 +97,8 @@ static const ConstantExpr *getMergedGlobalExpr(const Value *V) {
}
/// getOrCreateGlobalVariableDIE - get or create global variable DIE.
DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE(DIGlobalVariable GV) {
DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE(
const MDGlobalVariable *GV) {
// Check for pre-existence.
if (DIE *Die = getDIE(GV))
return Die;
@ -632,7 +633,7 @@ DwarfCompileUnit::constructAbstractSubprogramScopeDIE(LexicalScope *Scope) {
}
std::unique_ptr<DIE>
DwarfCompileUnit::constructImportedEntityDIE(const DIImportedEntity &Module) {
DwarfCompileUnit::constructImportedEntityDIE(const MDImportedEntity *Module) {
std::unique_ptr<DIE> IMDie = make_unique<DIE>((dwarf::Tag)Module->getTag());
insertDIE(Module, IMDie.get());
DIE *EntityDie;
@ -687,8 +688,8 @@ void DwarfCompileUnit::collectDeadVariables(const MDSubprogram *SP) {
if (!SPDIE)
SPDIE = getDIE(SP);
assert(SPDIE);
for (DIVariable DV : Variables) {
DbgVariable NewVar(DV, nullptr, DIExpression(), DD);
for (const MDLocalVariable *DV : Variables) {
DbgVariable NewVar(DV, /* IA */ nullptr, /* Expr */ nullptr, DD);
auto VariableDie = constructVariableDIE(NewVar);
applyVariableAttributes(NewVar, *VariableDie);
SPDIE->addChild(std::move(VariableDie));
@ -763,7 +764,7 @@ void DwarfCompileUnit::addComplexAddress(const DbgVariable &DV, DIE &Die,
DIELoc *Loc = new (DIEValueAllocator) DIELoc();
DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
assert(DV.getExpression().size() == 1);
DIExpression Expr = DV.getExpression().back();
const MDExpression *Expr = DV.getExpression().back();
bool ValidReg;
if (Location.getOffset()) {
ValidReg = DwarfExpr.AddMachineRegIndirect(Location.getReg(),

View File

@ -79,7 +79,7 @@ public:
void applyStmtList(DIE &D);
/// getOrCreateGlobalVariableDIE - get or create global variable DIE.
DIE *getOrCreateGlobalVariableDIE(DIGlobalVariable GV);
DIE *getOrCreateGlobalVariableDIE(const MDGlobalVariable *GV);
/// addLabelAddress - Add a dwarf label attribute data and value using
/// either DW_FORM_addr or DW_FORM_GNU_addr_index.
@ -156,7 +156,7 @@ public:
/// \brief Construct import_module DIE.
std::unique_ptr<DIE>
constructImportedEntityDIE(const DIImportedEntity &Module);
constructImportedEntityDIE(const MDImportedEntity *Module);
void finishSubprogramDefinition(const MDSubprogram *SP);

View File

@ -422,10 +422,9 @@ DwarfDebug::constructDwarfCompileUnit(const MDCompileUnit *DIUnit) {
}
void DwarfDebug::constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
const MDNode *N) {
DIImportedEntity Module = cast<MDImportedEntity>(N);
if (DIE *D = TheCU.getOrCreateContextDIE(Module->getScope()))
D->addChild(TheCU.constructImportedEntityDIE(Module));
const MDImportedEntity *N) {
if (DIE *D = TheCU.getOrCreateContextDIE(N->getScope()))
D->addChild(TheCU.constructImportedEntityDIE(N));
}
// Emit all Dwarf sections that should come prior to the content. Create
@ -661,8 +660,9 @@ void DwarfDebug::endModule() {
}
// Find abstract variable, if any, associated with Var.
DbgVariable *DwarfDebug::getExistingAbstractVariable(InlinedVariable IV,
DIVariable &Cleansed) {
DbgVariable *
DwarfDebug::getExistingAbstractVariable(InlinedVariable IV,
const MDLocalVariable *&Cleansed) {
// More then one inlined variable corresponds to one abstract variable.
Cleansed = IV.first;
auto I = AbstractVariables.find(Cleansed);
@ -672,21 +672,21 @@ DbgVariable *DwarfDebug::getExistingAbstractVariable(InlinedVariable IV,
}
DbgVariable *DwarfDebug::getExistingAbstractVariable(InlinedVariable IV) {
DIVariable Cleansed;
const MDLocalVariable *Cleansed;
return getExistingAbstractVariable(IV, Cleansed);
}
void DwarfDebug::createAbstractVariable(const DIVariable &Var,
void DwarfDebug::createAbstractVariable(const MDLocalVariable *Var,
LexicalScope *Scope) {
auto AbsDbgVariable =
make_unique<DbgVariable>(Var, nullptr, DIExpression(), this);
make_unique<DbgVariable>(Var, /* IA */ nullptr, /* Expr */ nullptr, this);
InfoHolder.addScopeVariable(Scope, AbsDbgVariable.get());
AbstractVariables[Var] = std::move(AbsDbgVariable);
}
void DwarfDebug::ensureAbstractVariableIsCreated(InlinedVariable IV,
const MDNode *ScopeNode) {
DIVariable Cleansed;
const MDLocalVariable *Cleansed = nullptr;
if (getExistingAbstractVariable(IV, Cleansed))
return;
@ -696,7 +696,7 @@ void DwarfDebug::ensureAbstractVariableIsCreated(InlinedVariable IV,
void DwarfDebug::ensureAbstractVariableIsCreatedIfScoped(
InlinedVariable IV, const MDNode *ScopeNode) {
DIVariable Cleansed;
const MDLocalVariable *Cleansed = nullptr;
if (getExistingAbstractVariable(IV, Cleansed))
return;
@ -722,7 +722,7 @@ void DwarfDebug::collectVariableInfoFromMMITable(
if (!Scope)
continue;
DIExpression Expr = cast_or_null<MDExpression>(VI.Expr);
const MDExpression *Expr = cast_or_null<MDExpression>(VI.Expr);
ensureAbstractVariableIsCreatedIfScoped(Var, Scope->getScopeNode());
auto RegVar =
make_unique<DbgVariable>(Var.first, Var.second, Expr, this, VI.Slot);
@ -757,7 +757,7 @@ static DebugLocEntry::Value getDebugLocValue(const MachineInstr *MI) {
}
/// Determine whether two variable pieces overlap.
static bool piecesOverlap(DIExpression P1, DIExpression P2) {
static bool piecesOverlap(const MDExpression *P1, const MDExpression *P2) {
if (!P1->isBitPiece() || !P2->isBitPiece())
return true;
unsigned l1 = P1->getBitPieceOffset();
@ -809,7 +809,7 @@ DwarfDebug::buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
}
// If this piece overlaps with any open ranges, truncate them.
DIExpression DIExpr = Begin->getDebugExpression();
const MDExpression *DIExpr = Begin->getDebugExpression();
auto Last = std::remove_if(OpenRanges.begin(), OpenRanges.end(),
[&](DebugLocEntry::Value R) {
return piecesOverlap(DIExpr, R.getExpression());
@ -930,15 +930,14 @@ void DwarfDebug::collectVariableInfo(DwarfCompileUnit &TheCU,
}
// Collect info for variables that were optimized out.
for (DIVariable DV : SP->getVariables()) {
for (const MDLocalVariable *DV : SP->getVariables()) {
if (!Processed.insert(InlinedVariable(DV, nullptr)).second)
continue;
if (LexicalScope *Scope = LScopes.findLexicalScope(DV->getScope())) {
ensureAbstractVariableIsCreatedIfScoped(InlinedVariable(DV, nullptr),
Scope->getScopeNode());
DIExpression NoExpr;
ConcreteVariables.push_back(
make_unique<DbgVariable>(DV, nullptr, NoExpr, this));
ConcreteVariables.push_back(make_unique<DbgVariable>(
DV, /* IA */ nullptr, /* Expr */ nullptr, this));
InfoHolder.addScopeVariable(Scope, ConcreteVariables.back().get());
}
}
@ -1129,14 +1128,14 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {
// The first mention of a function argument gets the CurrentFnBegin
// label, so arguments are visible when breaking at function entry.
DIVariable DIVar = Ranges.front().first->getDebugVariable();
const MDLocalVariable *DIVar = Ranges.front().first->getDebugVariable();
if (DIVar->getTag() == dwarf::DW_TAG_arg_variable &&
getDISubprogram(DIVar->getScope())->describes(MF->getFunction())) {
LabelsBeforeInsn[Ranges.front().first] = Asm->getFunctionBegin();
if (Ranges.front().first->getDebugExpression()->isBitPiece()) {
// Mark all non-overlapping initial pieces.
for (auto I = Ranges.begin(); I != Ranges.end(); ++I) {
DIExpression Piece = I->first->getDebugExpression();
const MDExpression *Piece = I->first->getDebugExpression();
if (std::all_of(Ranges.begin(), I,
[&](DbgValueHistoryMap::InstrRange Pred) {
return !piecesOverlap(Piece, Pred.first->getDebugExpression());
@ -1219,7 +1218,7 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
for (LexicalScope *AScope : LScopes.getAbstractScopesList()) {
auto *SP = cast<MDSubprogram>(AScope->getScopeNode());
// Collect info for variables that were optimized out.
for (DIVariable DV : SP->getVariables()) {
for (const MDLocalVariable *DV : SP->getVariables()) {
if (!ProcessedVars.insert(InlinedVariable(DV, nullptr)).second)
continue;
ensureAbstractVariableIsCreated(InlinedVariable(DV, nullptr),
@ -1488,7 +1487,7 @@ static void emitDebugLocValue(const AsmPrinter &AP, const MDBasicType *BT,
DwarfExpr.AddUnsignedConstant(Value.getInt());
} else if (Value.isLocation()) {
MachineLocation Loc = Value.getLoc();
DIExpression Expr = Value.getExpression();
const MDExpression *Expr = Value.getExpression();
if (!Expr || !Expr->getNumElements())
// Regular entry.
AP.EmitDwarfRegOp(Streamer, Loc);
@ -1523,7 +1522,7 @@ void DebugLocEntry::finalize(const AsmPrinter &AP, DebugLocStream &Locs,
unsigned Offset = 0;
for (auto Piece : Values) {
DIExpression Expr = Piece.getExpression();
const MDExpression *Expr = Piece.getExpression();
unsigned PieceOffset = Expr->getBitPieceOffset();
unsigned PieceSize = Expr->getBitPieceSize();
assert(Offset <= PieceOffset && "overlapping or duplicate pieces");

View File

@ -75,9 +75,10 @@ public:
/// - Variables that are described by multiple MMI table entries have multiple
/// expressions and frame indices.
class DbgVariable {
DIVariable Var; /// Variable Descriptor.
DILocation IA; /// Inlined at location.
SmallVector<DIExpression, 1> Expr; /// Complex address location expression.
const MDLocalVariable *Var; /// Variable Descriptor.
const MDLocation *IA; /// Inlined at location.
SmallVector<const MDExpression *, 1>
Expr; /// Complex address location expression.
DIE *TheDIE; /// Variable DIE.
unsigned DebugLocListIndex; /// Offset in DebugLocs.
const MachineInstr *MInsn; /// DBG_VALUE instruction of the variable.
@ -85,9 +86,9 @@ class DbgVariable {
DwarfDebug *DD;
public:
/// Construct a DbgVariable from a DIVariable.
DbgVariable(DIVariable V, DILocation IA, DIExpression E, DwarfDebug *DD,
int FI = ~0)
/// Construct a DbgVariable from a variable.
DbgVariable(const MDLocalVariable *V, const MDLocation *IA,
const MDExpression *E, DwarfDebug *DD, int FI = ~0)
: Var(V), IA(IA), Expr(1, E), TheDIE(nullptr), DebugLocListIndex(~0U),
MInsn(nullptr), DD(DD) {
FrameIndex.push_back(FI);
@ -105,9 +106,9 @@ public:
}
// Accessors.
DIVariable getVariable() const { return Var; }
DILocation getInlinedAt() const { return IA; }
const ArrayRef<DIExpression> getExpression() const { return Expr; }
const MDLocalVariable *getVariable() const { return Var; }
const MDLocation *getInlinedAt() const { return IA; }
const ArrayRef<const MDExpression *> getExpression() const { return Expr; }
void setDIE(DIE &D) { TheDIE = &D; }
DIE *getDIE() const { return TheDIE; }
void setDebugLocListIndex(unsigned O) { DebugLocListIndex = O; }
@ -119,7 +120,7 @@ public:
void addMMIEntry(const DbgVariable &V) {
assert(DebugLocListIndex == ~0U && !MInsn && "not an MMI entry");
assert(V.DebugLocListIndex == ~0U && !V.MInsn && "not an MMI entry");
assert(V.Var == Var && "conflicting DIVariable");
assert(V.Var == Var && "conflicting variable");
assert(V.IA == IA && "conflicting inlined-at location");
if (V.getFrameIndex().back() != ~0) {
@ -128,10 +129,11 @@ public:
Expr.append(E.begin(), E.end());
FrameIndex.append(FI.begin(), FI.end());
}
assert(Expr.size() > 1
? std::all_of(Expr.begin(), Expr.end(),
[](DIExpression &E) { return E->isBitPiece(); })
: (true && "conflicting locations for variable"));
assert(Expr.size() > 1 ? std::all_of(Expr.begin(), Expr.end(),
[](const MDExpression *E) {
return E->isBitPiece();
})
: (true && "conflicting locations for variable"));
}
// Translate tag to proper Dwarf tag.
@ -334,9 +336,9 @@ class DwarfDebug : public AsmPrinterHandler {
/// \brief Find abstract variable associated with Var.
DbgVariable *getExistingAbstractVariable(InlinedVariable IV,
DIVariable &Cleansed);
const MDLocalVariable *&Cleansed);
DbgVariable *getExistingAbstractVariable(InlinedVariable IV);
void createAbstractVariable(const DIVariable &DV, LexicalScope *Scope);
void createAbstractVariable(const MDLocalVariable *DV, LexicalScope *Scope);
void ensureAbstractVariableIsCreated(InlinedVariable Var,
const MDNode *Scope);
void ensureAbstractVariableIsCreatedIfScoped(InlinedVariable Var,
@ -455,7 +457,7 @@ class DwarfDebug : public AsmPrinterHandler {
/// \brief Construct imported_module or imported_declaration DIE.
void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
const MDNode *N);
const MDImportedEntity *N);
/// \brief Register a source line with debug info. Returns the unique
/// label that was emitted and which provides correspondence to the

View File

@ -192,7 +192,7 @@ static unsigned getOffsetOrZero(unsigned OffsetInBits,
return OffsetInBits;
}
bool DwarfExpression::AddMachineRegExpression(DIExpression Expr,
bool DwarfExpression::AddMachineRegExpression(const MDExpression *Expr,
unsigned MachineReg,
unsigned PieceOffsetInBits) {
auto I = Expr->expr_op_begin();
@ -259,7 +259,7 @@ void DwarfExpression::AddExpression(MDExpression::expr_op_iterator I,
EmitOp(dwarf::DW_OP_deref);
break;
default:
llvm_unreachable("unhandled opcode found in DIExpression");
llvm_unreachable("unhandled opcode found in expression");
}
}
}

View File

@ -88,11 +88,12 @@ public:
/// Emit an unsigned constant.
void AddUnsignedConstant(unsigned Value);
/// Emit an entire DIExpression on top of a machine register location.
/// \brief Emit an entire expression on top of a machine register location.
///
/// \param PieceOffsetInBits If this is one piece out of a fragmented
/// location, this is the offset of the piece inside the entire variable.
/// \return false if no DWARF register exists for MachineReg.
bool AddMachineRegExpression(DIExpression Expr, unsigned MachineReg,
bool AddMachineRegExpression(const MDExpression *Expr, unsigned MachineReg,
unsigned PieceOffsetInBits = 0);
/// Emit a the operations remaining the DIExpressionIterator I.
/// \param PieceOffsetInBits If this is one piece out of a fragmented

View File

@ -137,7 +137,7 @@ void DwarfFile::emitStrings(const MCSection *StrSection,
bool DwarfFile::addScopeVariable(LexicalScope *LS, DbgVariable *Var) {
SmallVectorImpl<DbgVariable *> &Vars = ScopeVariables[LS];
DIVariable DV = Var->getVariable();
const MDLocalVariable *DV = Var->getVariable();
// Variables with positive arg numbers are parameters.
if (unsigned ArgNum = DV->getArg()) {
// Keep all parameters in order at the start of the variable list to ensure

View File

@ -354,14 +354,14 @@ void DwarfUnit::addSourceLine(DIE &Die, unsigned Line, StringRef File,
addUInt(Die, dwarf::DW_AT_decl_line, None, Line);
}
void DwarfUnit::addSourceLine(DIE &Die, DIVariable V) {
void DwarfUnit::addSourceLine(DIE &Die, const MDLocalVariable *V) {
assert(V);
addSourceLine(Die, V->getLine(), V->getScope()->getFilename(),
V->getScope()->getDirectory());
}
void DwarfUnit::addSourceLine(DIE &Die, DIGlobalVariable G) {
void DwarfUnit::addSourceLine(DIE &Die, const MDGlobalVariable *G) {
assert(G);
addSourceLine(Die, G->getLine(), G->getFilename(), G->getDirectory());
@ -379,7 +379,7 @@ void DwarfUnit::addSourceLine(DIE &Die, const MDType *Ty) {
addSourceLine(Die, Ty->getLine(), Ty->getFilename(), Ty->getDirectory());
}
void DwarfUnit::addSourceLine(DIE &Die, DIObjCProperty Ty) {
void DwarfUnit::addSourceLine(DIE &Die, const MDObjCProperty *Ty) {
assert(Ty);
addSourceLine(Die, Ty->getLine(), Ty->getFilename(), Ty->getDirectory());
@ -976,7 +976,7 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDCompositeType *CTy) {
} else {
constructMemberDIE(Buffer, DDTy);
}
} else if (DIObjCProperty Property = dyn_cast<MDObjCProperty>(Element)) {
} else if (auto *Property = dyn_cast<MDObjCProperty>(Element)) {
DIE &ElemDie = createAndAddDIE(Property->getTag(), Buffer);
StringRef PropertyName = Property->getName();
addString(ElemDie, dwarf::DW_AT_APPLE_property_name, PropertyName);
@ -1057,8 +1057,8 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDCompositeType *CTy) {
}
}
void DwarfUnit::constructTemplateTypeParameterDIE(DIE &Buffer,
DITemplateTypeParameter TP) {
void DwarfUnit::constructTemplateTypeParameterDIE(
DIE &Buffer, const MDTemplateTypeParameter *TP) {
DIE &ParamDIE =
createAndAddDIE(dwarf::DW_TAG_template_type_parameter, Buffer);
// Add the type if it exists, it could be void and therefore no type.
@ -1068,9 +1068,8 @@ void DwarfUnit::constructTemplateTypeParameterDIE(DIE &Buffer,
addString(ParamDIE, dwarf::DW_AT_name, TP->getName());
}
void
DwarfUnit::constructTemplateValueParameterDIE(DIE &Buffer,
DITemplateValueParameter VP) {
void DwarfUnit::constructTemplateValueParameterDIE(
DIE &Buffer, const MDTemplateValueParameter *VP) {
DIE &ParamDIE = createAndAddDIE(VP->getTag(), Buffer);
// Add the type if there is one, template template and template parameter
@ -1270,7 +1269,8 @@ void DwarfUnit::applySubprogramAttributes(const MDSubprogram *SP, DIE &SPDie,
addFlag(SPDie, dwarf::DW_AT_explicit);
}
void DwarfUnit::constructSubrangeDIE(DIE &Buffer, DISubrange SR, DIE *IndexTy) {
void DwarfUnit::constructSubrangeDIE(DIE &Buffer, const MDSubrange *SR,
DIE *IndexTy) {
DIE &DW_Subrange = createAndAddDIE(dwarf::DW_TAG_subrange_type, Buffer);
addDIEEntry(DW_Subrange, dwarf::DW_AT_type, *IndexTy);

View File

@ -246,12 +246,12 @@ public:
/// \brief Add location information to specified debug information entry.
void addSourceLine(DIE &Die, unsigned Line, StringRef File,
StringRef Directory);
void addSourceLine(DIE &Die, DIVariable V);
void addSourceLine(DIE &Die, DIGlobalVariable G);
void addSourceLine(DIE &Die, const MDLocalVariable *V);
void addSourceLine(DIE &Die, const MDGlobalVariable *G);
void addSourceLine(DIE &Die, const MDSubprogram *SP);
void addSourceLine(DIE &Die, const MDType *Ty);
void addSourceLine(DIE &Die, const MDNamespace *NS);
void addSourceLine(DIE &Die, DIObjCProperty Ty);
void addSourceLine(DIE &Die, const MDObjCProperty *Ty);
/// \brief Add constant value entry in variable DIE.
void addConstantValue(DIE &Die, const MachineOperand &MO, const MDType *Ty);
@ -355,14 +355,14 @@ private:
void constructTypeDIE(DIE &Buffer, const MDBasicType *BTy);
void constructTypeDIE(DIE &Buffer, const MDDerivedType *DTy);
void constructTypeDIE(DIE &Buffer, const MDSubroutineType *DTy);
void constructSubrangeDIE(DIE &Buffer, DISubrange SR, DIE *IndexTy);
void constructSubrangeDIE(DIE &Buffer, const MDSubrange *SR, DIE *IndexTy);
void constructArrayTypeDIE(DIE &Buffer, const MDCompositeType *CTy);
void constructEnumTypeDIE(DIE &Buffer, const MDCompositeType *CTy);
void constructMemberDIE(DIE &Buffer, const MDDerivedType *DT);
void constructTemplateTypeParameterDIE(DIE &Buffer,
DITemplateTypeParameter TP);
const MDTemplateTypeParameter *TP);
void constructTemplateValueParameterDIE(DIE &Buffer,
DITemplateValueParameter TVP);
const MDTemplateValueParameter *TVP);
/// \brief Return the default lower bound for an array.
///

View File

@ -394,7 +394,7 @@ static void printExtendedName(raw_ostream &OS, const MDLocalVariable *V,
}
void UserValue::print(raw_ostream &OS, const TargetRegisterInfo *TRI) {
DIVariable DV = cast<MDLocalVariable>(Variable);
auto *DV = cast<MDLocalVariable>(Variable);
OS << "!\"";
printExtendedName(OS, DV, dl);

View File

@ -1619,7 +1619,7 @@ void MachineInstr::print(raw_ostream &OS, bool SkipOpers) const {
}
if (isDebugValue() && MO.isMetadata()) {
// Pretty print DBG_VALUE instructions.
DIVariable DIV = dyn_cast<MDLocalVariable>(MO.getMetadata());
auto *DIV = dyn_cast<MDLocalVariable>(MO.getMetadata());
if (DIV && !DIV->getName().empty())
OS << "!\"" << DIV->getName() << '\"';
else
@ -1710,7 +1710,7 @@ void MachineInstr::print(raw_ostream &OS, bool SkipOpers) const {
// Print debug location information.
if (isDebugValue() && getOperand(e - 2).isMetadata()) {
if (!HaveSemi) OS << ";";
DIVariable DV = cast<MDLocalVariable>(getOperand(e - 2).getMetadata());
auto *DV = cast<MDLocalVariable>(getOperand(e - 2).getMetadata());
OS << " line no:" << DV->getLine();
if (auto *InlinedAt = debugLoc->getInlinedAt()) {
DebugLoc InlinedAtDL(InlinedAt);

View File

@ -4463,8 +4463,7 @@ bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
// Ignore inlined function arguments here.
//
// FIXME: Should we be checking DL->inlinedAt() to determine this?
DIVariable DV(Variable);
if (!DV->getScope()->getSubprogram()->describes(MF.getFunction()))
if (!Variable->getScope()->getSubprogram()->describes(MF.getFunction()))
return false;
Optional<MachineOperand> Op;
@ -4672,9 +4671,8 @@ SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, unsigned Intrinsic) {
if (const BitCastInst *BCI = dyn_cast<BitCastInst>(Address))
Address = BCI->getOperand(0);
// Parameters are handled specially.
bool isParameter =
(DIVariable(Variable)->getTag() == dwarf::DW_TAG_arg_variable ||
isa<Argument>(Address));
bool isParameter = Variable->getTag() == dwarf::DW_TAG_arg_variable ||
isa<Argument>(Address);
const AllocaInst *AI = dyn_cast<AllocaInst>(Address);

View File

@ -321,11 +321,8 @@ bool StripDeadDebugInfo::runOnModule(Module &M) {
}
// Create our live global variable list.
MDGlobalVariableArray GVs = DIC->getGlobalVariables();
bool GlobalVariableChange = false;
for (unsigned i = 0, e = GVs.size(); i != e; ++i) {
DIGlobalVariable DIG = GVs[i];
for (MDGlobalVariable *DIG : DIC->getGlobalVariables()) {
// Make sure we only visit each global variable only once.
if (!VisitedSet.insert(DIG).second)
continue;

View File

@ -1166,9 +1166,9 @@ public:
} else {
continue;
}
DIB.insertDbgValueIntrinsic(Arg, 0, DIVariable(DVI->getVariable()),
DIExpression(DVI->getExpression()),
DVI->getDebugLoc(), Inst);
DIB.insertDbgValueIntrinsic(Arg, 0, DVI->getVariable(),
DVI->getExpression(), DVI->getDebugLoc(),
Inst);
}
}
};
@ -4181,15 +4181,15 @@ bool SROA::splitAlloca(AllocaInst &AI, AllocaSlices &AS) {
// Migrate debug information from the old alloca to the new alloca(s)
// and the individial partitions.
if (DbgDeclareInst *DbgDecl = FindAllocaDbgDeclare(&AI)) {
DIVariable Var(DbgDecl->getVariable());
DIExpression Expr(DbgDecl->getExpression());
auto *Var = DbgDecl->getVariable();
auto *Expr = DbgDecl->getExpression();
DIBuilder DIB(*AI.getParent()->getParent()->getParent(),
/*AllowUnresolved*/ false);
bool IsSplit = Pieces.size() > 1;
for (auto Piece : Pieces) {
// Create a piece expression describing the new partition or reuse AI's
// expression if there is only one partition.
DIExpression PieceExpr = Expr;
auto *PieceExpr = Expr;
if (IsSplit || Expr->isBitPiece()) {
// If this alloca is already a scalar replacement of a larger aggregate,
// Piece.Offset describes the offset inside the scalar.

View File

@ -224,7 +224,7 @@ unsigned SampleProfileLoader::getInstWeight(Instruction &Inst) {
if (Lineno < HeaderLineno)
return 0;
DILocation DIL = DLoc.get();
const MDLocation *DIL = DLoc;
int LOffset = Lineno - HeaderLineno;
unsigned Discriminator = DIL->getDiscriminator();
unsigned Weight = Samples->samplesAt(LOffset, Discriminator);

View File

@ -1117,9 +1117,9 @@ public:
} else {
continue;
}
DIB->insertDbgValueIntrinsic(Arg, 0, DIVariable(DVI->getVariable()),
DIExpression(DVI->getExpression()),
DVI->getDebugLoc(), Inst);
DIB->insertDbgValueIntrinsic(Arg, 0, DVI->getVariable(),
DVI->getExpression(), DVI->getDebugLoc(),
Inst);
}
}
};

View File

@ -174,14 +174,14 @@ bool AddDiscriminators::runOnFunction(Function &F) {
for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) {
BasicBlock *B = I;
TerminatorInst *Last = B->getTerminator();
DILocation LastDIL = Last->getDebugLoc().get();
const MDLocation *LastDIL = Last->getDebugLoc();
if (!LastDIL)
continue;
for (unsigned I = 0; I < Last->getNumSuccessors(); ++I) {
BasicBlock *Succ = Last->getSuccessor(I);
Instruction *First = Succ->getFirstNonPHIOrDbgOrLifetime();
DILocation FirstDIL = First->getDebugLoc().get();
const MDLocation *FirstDIL = First->getDebugLoc();
if (!FirstDIL)
continue;

View File

@ -978,7 +978,7 @@ unsigned llvm::getOrEnforceKnownAlignment(Value *V, unsigned PrefAlign,
///
/// See if there is a dbg.value intrinsic for DIVar before I.
static bool LdStHasDebugValue(DIVariable &DIVar, Instruction *I) {
static bool LdStHasDebugValue(const MDLocalVariable *DIVar, Instruction *I) {
// Since we can't guarantee that the original dbg.declare instrinsic
// is removed by LowerDbgDeclare(), we need to make sure that we are
// not inserting the same dbg.value intrinsic over and over.
@ -998,8 +998,8 @@ static bool LdStHasDebugValue(DIVariable &DIVar, Instruction *I) {
/// that has an associated llvm.dbg.decl intrinsic.
bool llvm::ConvertDebugDeclareToDebugValue(DbgDeclareInst *DDI,
StoreInst *SI, DIBuilder &Builder) {
DIVariable DIVar = DDI->getVariable();
DIExpression DIExpr = DDI->getExpression();
auto *DIVar = DDI->getVariable();
auto *DIExpr = DDI->getExpression();
assert(DIVar && "Missing variable");
if (LdStHasDebugValue(DIVar, SI))
@ -1025,8 +1025,8 @@ bool llvm::ConvertDebugDeclareToDebugValue(DbgDeclareInst *DDI,
/// that has an associated llvm.dbg.decl intrinsic.
bool llvm::ConvertDebugDeclareToDebugValue(DbgDeclareInst *DDI,
LoadInst *LI, DIBuilder &Builder) {
DIVariable DIVar = DDI->getVariable();
DIExpression DIExpr = DDI->getExpression();
auto *DIVar = DDI->getVariable();
auto *DIExpr = DDI->getExpression();
assert(DIVar && "Missing variable");
if (LdStHasDebugValue(DIVar, LI))
@ -1075,9 +1075,9 @@ bool llvm::LowerDbgDeclare(Function &F) {
// This is a call by-value or some other instruction that
// takes a pointer to the variable. Insert a *value*
// intrinsic that describes the alloca.
DIB.insertDbgValueIntrinsic(AI, 0, DIVariable(DDI->getVariable()),
DIExpression(DDI->getExpression()),
DDI->getDebugLoc(), CI);
DIB.insertDbgValueIntrinsic(AI, 0, DDI->getVariable(),
DDI->getExpression(), DDI->getDebugLoc(),
CI);
}
DDI->eraseFromParent();
}
@ -1103,8 +1103,8 @@ bool llvm::replaceDbgDeclareForAlloca(AllocaInst *AI, Value *NewAllocaAddress,
if (!DDI)
return false;
DebugLoc Loc = DDI->getDebugLoc();
DIVariable DIVar = DDI->getVariable();
DIExpression DIExpr = DDI->getExpression();
auto *DIVar = DDI->getVariable();
auto *DIExpr = DDI->getExpression();
assert(DIVar && "Missing variable");
if (Deref) {

View File

@ -94,20 +94,18 @@ public:
OS << "]";
}
if (const DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(I)) {
DIVariable Var(DDI->getVariable());
if (!Padded) {
OS.PadToColumn(50);
OS << ";";
}
OS << " [debug variable = " << Var->getName() << "]";
OS << " [debug variable = " << DDI->getVariable()->getName() << "]";
}
else if (const DbgValueInst *DVI = dyn_cast<DbgValueInst>(I)) {
DIVariable Var(DVI->getVariable());
if (!Padded) {
OS.PadToColumn(50);
OS << ";";
}
OS << " [debug variable = " << Var->getName() << "]";
OS << " [debug variable = " << DVI->getVariable()->getName() << "]";
}
}
}

View File

@ -254,9 +254,9 @@ protected:
// Create a local variable around the alloca
auto *IntType =
DBuilder.createBasicType("int", 32, 0, dwarf::DW_ATE_signed);
DIExpression E = DBuilder.createExpression();
DIVariable Variable = DBuilder.createLocalVariable(
dwarf::DW_TAG_auto_variable, Subprogram, "x", File, 5, IntType, true);
auto *E = DBuilder.createExpression();
auto *Variable = DBuilder.createLocalVariable(
dwarf::DW_TAG_auto_variable, Subprogram, "x", File, 5, IntType, true);
auto *DL = MDLocation::get(Subprogram->getContext(), 5, 0, Subprogram);
DBuilder.insertDeclare(Alloca, Variable, E, DL, Store);
DBuilder.insertDbgValueIntrinsic(AllocaContent, 0, Variable, E, DL,