1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

DebugInfo: Remove DIDescriptor::Verify()

Remove `DIDescriptor::Verify()` and the `Verify()`s from subclasses.
They had already been gutted, and just did an `isa<>` check.

In a couple of cases I've temporarily dropped the check entirely, but
subsequent commits are going to disallow conversions to the
`DIDescriptor`s directly from `MDNode`, so the checks will come back in
another form soon enough.

llvm-svn: 234201
This commit is contained in:
Duncan P. N. Exon Smith 2015-04-06 19:49:39 +00:00
parent 3b24416de4
commit ea3fb29a5a
12 changed files with 17 additions and 135 deletions

View File

@ -248,9 +248,7 @@ public:
/// this DBG_VALUE instruction.
DIVariable getDebugVariable() const {
assert(isDebugValue() && "not a DBG_VALUE");
DIVariable Var(getOperand(2).getMetadata());
assert(Var.Verify() && "not a DIVariable");
return Var;
return cast<MDLocalVariable>(getOperand(2).getMetadata());
}
/// \brief Return the complex address expression referenced by

View File

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

View File

@ -98,8 +98,6 @@ protected:
public:
explicit DIDescriptor(const MDNode *N = nullptr) : DbgNode(N) {}
bool Verify() const;
MDNode *get() const { return const_cast<MDNode *>(DbgNode); }
operator MDNode *() const { return get(); }
MDNode *operator->() const { return get(); }
@ -188,7 +186,6 @@ public:
int64_t getLo() const { return get()->getLo(); }
int64_t getCount() const { return get()->getCount(); }
bool Verify() const;
};
/// \brief This descriptor holds an array of nodes with type T.
@ -227,7 +224,6 @@ public:
StringRef getName() const { return get()->getName(); }
int64_t getEnumValue() const { return get()->getValue(); }
bool Verify() const;
};
template <typename T> class DIRef;
@ -355,8 +351,6 @@ public:
return *get();
}
bool Verify() const;
DIScopeRef getContext() const { return DIScopeRef::get(get()->getScope()); }
StringRef getName() const { return get()->getName(); }
unsigned getLineNumber() const { return get()->getLine(); }
@ -416,8 +410,6 @@ public:
}
unsigned getEncoding() const { return get()->getEncoding(); }
bool Verify() const;
};
/// \brief A simple derived type
@ -465,8 +457,6 @@ public:
return nullptr;
}
bool Verify() const;
};
/// \brief Types that refer to multiple other types.
@ -528,8 +518,6 @@ public:
return DIArray(get()->getTemplateParams());
}
MDString *getIdentifier() const { return get()->getRawIdentifier(); }
bool Verify() const;
};
class DISubroutineType : public DICompositeType {
@ -568,7 +556,6 @@ public:
/// \brief Retrieve the MDNode for the directory/file pair.
MDNode *getFileNode() const { return get(); }
bool Verify() const;
};
/// \brief A wrapper for a compile unit.
@ -614,8 +601,6 @@ public:
return get()->getSplitDebugFilename();
}
unsigned getEmissionKind() const { return get()->getEmissionKind(); }
bool Verify() const;
};
/// \brief This is a wrapper for a subprogram (e.g. a function).
@ -662,8 +647,6 @@ public:
return DITypeRef::get(get()->getContainingType());
}
bool Verify() const;
/// \brief Check if this provides debugging information for the function F.
bool describes(const Function *F);
@ -744,7 +727,6 @@ public:
return N->getColumn();
return 0;
}
bool Verify() const;
};
/// \brief This is a wrapper for a lexical block with a filename change.
@ -768,7 +750,6 @@ public:
unsigned getColumnNumber() const { return getScope().getColumnNumber(); }
DILexicalBlock getScope() const { return DILexicalBlock(get()->getScope()); }
unsigned getDiscriminator() const { return get()->getDiscriminator(); }
bool Verify() const;
};
/// \brief A wrapper for a C++ style name space.
@ -790,7 +771,6 @@ public:
StringRef getName() const { return get()->getName(); }
unsigned getLineNumber() const { return get()->getLine(); }
DIScope getContext() const { return DIScope(get()->getScope()); }
bool Verify() const;
};
/// \brief This is a wrapper for template type parameter.
@ -813,7 +793,6 @@ public:
StringRef getName() const { return get()->getName(); }
DITypeRef getType() const { return DITypeRef::get(get()->getType()); }
bool Verify() const;
};
/// \brief This is a wrapper for template value parameter.
@ -837,7 +816,6 @@ public:
StringRef getName() const { return get()->getName(); }
DITypeRef getType() const { return DITypeRef::get(get()->getType()); }
Metadata *getValue() const { return get()->getValue(); }
bool Verify() const;
};
/// \brief This is a wrapper for a global variable.
@ -880,8 +858,6 @@ public:
DIDerivedType getStaticDataMemberDeclaration() const {
return DIDerivedType(get()->getStaticDataMemberDeclaration());
}
bool Verify() const;
};
/// \brief This is a wrapper for a variable (e.g. parameter, local, global etc).
@ -922,8 +898,6 @@ public:
/// \brief If this variable is inlined then return inline location.
MDNode *getInlinedAt() const { return DIDescriptor(get()->getInlinedAt()); }
bool Verify() const;
/// \brief Check if this is a "__block" variable (Apple Blocks).
bool isBlockByrefVariable(const DITypeIdentifierMap &Map) const {
return (getType().resolve(Map)).isBlockByrefStruct();
@ -960,9 +934,6 @@ public:
return *get();
}
// Don't call this. Call isValid() directly.
bool Verify() const = delete;
/// \brief Return the number of elements in the complex expression.
unsigned getNumElements() const { return get()->getNumElements(); }
@ -1063,7 +1034,6 @@ public:
}
StringRef getFilename() const { return getScope().getFilename(); }
StringRef getDirectory() const { return getScope().getDirectory(); }
bool Verify() const;
bool atSameLineAs(const DILocation &Other) const {
return (getLineNumber() == Other.getLineNumber() &&
getFilename() == Other.getFilename());
@ -1140,8 +1110,6 @@ public:
/// \note Objective-C doesn't have an ODR, so there is no benefit in storing
/// the type as a DITypeRef here.
DIType getType() const { return DIType(get()->getType()); }
bool Verify() const;
};
/// \brief An imported module (C++ using directive or similar).
@ -1167,7 +1135,6 @@ public:
}
unsigned getLineNumber() const { return get()->getLine(); }
StringRef getName() const { return get()->getName(); }
bool Verify() const;
};
/// \brief Find subprogram that is enclosing this scope.

View File

@ -42,7 +42,7 @@ public:
}
Value(const MDNode *Var, const MDNode *Expr, MachineLocation Loc)
: Variable(Var), Expression(Expr), EntryKind(E_Location), Loc(Loc) {
assert(DIVariable(Var).Verify());
assert(isa<MDLocalVariable>(Var));
assert(DIExpression(Expr)->isValid());
}

View File

@ -637,8 +637,6 @@ DwarfCompileUnit::constructAbstractSubprogramScopeDIE(LexicalScope *Scope) {
std::unique_ptr<DIE>
DwarfCompileUnit::constructImportedEntityDIE(const DIImportedEntity &Module) {
assert(Module.Verify() &&
"Use one of the MDNode * overloads to handle invalid metadata");
std::unique_ptr<DIE> IMDie = make_unique<DIE>((dwarf::Tag)Module.getTag());
insertDIE(Module, IMDie.get());
DIE *EntityDie;

View File

@ -421,7 +421,6 @@ DwarfCompileUnit &DwarfDebug::constructDwarfCompileUnit(DICompileUnit DIUnit) {
void DwarfDebug::constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
const MDNode *N) {
DIImportedEntity Module(N);
assert(Module.Verify());
if (DIE *D = TheCU.getOrCreateContextDIE(Module.getContext()))
D->addChild(TheCU.constructImportedEntityDIE(Module));
}
@ -1499,9 +1498,10 @@ static void emitDebugLocValue(const AsmPrinter &AP,
Streamer);
// Regular entry.
if (Value.isInt()) {
DIBasicType BTy(DV.getType().resolve(TypeIdentifierMap));
if (BTy.Verify() && (BTy.getEncoding() == dwarf::DW_ATE_signed ||
BTy.getEncoding() == dwarf::DW_ATE_signed_char))
MDType *T = DV.getType().resolve(TypeIdentifierMap);
auto *B = dyn_cast<MDBasicType>(T);
if (B && (B->getEncoding() == dwarf::DW_ATE_signed ||
B->getEncoding() == dwarf::DW_ATE_signed_char))
DwarfExpr.AddSignedConstant(Value.getInt());
else
DwarfExpr.AddUnsignedConstant(Value.getInt());

View File

@ -88,7 +88,6 @@ public:
: Var(V), Expr(1, E), TheDIE(nullptr), DotDebugLocOffset(~0U),
MInsn(nullptr), DD(DD) {
FrameIndex.push_back(FI);
assert(Var.Verify());
assert(!E || E->isValid());
}

View File

@ -440,8 +440,6 @@ void DwarfUnit::addSourceLine(DIE &Die, DIObjCProperty Ty) {
/// addSourceLine - Add location information to specified debug information
/// entry.
void DwarfUnit::addSourceLine(DIE &Die, DINameSpace NS) {
assert(NS.Verify());
addSourceLine(Die, NS.getLineNumber(), NS.getFilename(), NS.getDirectory());
}
@ -1571,7 +1569,7 @@ void DwarfUnit::constructMemberDIE(DIE &Buffer, DIDerivedType DT) {
/// getOrCreateStaticMemberDIE - Create new DIE for C++ static member.
DIE *DwarfUnit::getOrCreateStaticMemberDIE(DIDerivedType DT) {
if (!DT.Verify())
if (!DT)
return nullptr;
// Construct the context before querying for the existence of the DIE in case

View File

@ -175,7 +175,6 @@ createImportedModule(LLVMContext &C, dwarf::Tag Tag, DIScope Context,
Metadata *NS, unsigned Line, StringRef Name,
SmallVectorImpl<TrackingMDNodeRef> &AllImportedModules) {
DIImportedEntity M = MDImportedEntity::get(C, Tag, Context, NS, Line, Name);
assert(M.Verify() && "Imported module should be valid");
AllImportedModules.emplace_back(M.get());
return M;
}
@ -741,33 +740,23 @@ DISubprogram DIBuilder::createMethod(DIDescriptor Context, StringRef Name,
DINameSpace DIBuilder::createNameSpace(DIDescriptor Scope, StringRef Name,
DIFile File, unsigned LineNo) {
DINameSpace R = MDNamespace::get(VMContext, getNonCompileUnitScope(Scope),
File, Name, LineNo);
assert(R.Verify() &&
"createNameSpace should return a verifiable DINameSpace");
return R;
return MDNamespace::get(VMContext, getNonCompileUnitScope(Scope), File, Name,
LineNo);
}
DILexicalBlockFile DIBuilder::createLexicalBlockFile(DIDescriptor Scope,
DIFile File,
unsigned Discriminator) {
DILexicalBlockFile R = MDLexicalBlockFile::get(
VMContext, Scope, File.getFileNode(), Discriminator);
assert(
R.Verify() &&
"createLexicalBlockFile should return a verifiable DILexicalBlockFile");
return R;
return MDLexicalBlockFile::get(VMContext, Scope, File.getFileNode(),
Discriminator);
}
DILexicalBlock DIBuilder::createLexicalBlock(DIDescriptor Scope, DIFile File,
unsigned Line, unsigned Col) {
// Make these distinct, to avoid merging two lexical blocks on the same
// file/line/column.
DILexicalBlock R = MDLexicalBlock::getDistinct(
VMContext, getNonCompileUnitScope(Scope), File.getFileNode(), Line, Col);
assert(R.Verify() &&
"createLexicalBlock should return a verifiable DILexicalBlock");
return R;
return MDLexicalBlock::getDistinct(VMContext, getNonCompileUnitScope(Scope),
File.getFileNode(), Line, Col);
}
static Value *getDbgIntrinsicValueImpl(LLVMContext &VMContext, Value *V) {

View File

@ -80,22 +80,6 @@ unsigned DIDescriptor::splitFlags(unsigned Flags,
return Flags;
}
bool DIDescriptor::Verify() const {
return DbgNode &&
(DIDerivedType(DbgNode).Verify() ||
DICompositeType(DbgNode).Verify() || DIBasicType(DbgNode).Verify() ||
DIVariable(DbgNode).Verify() || DISubprogram(DbgNode).Verify() ||
DIGlobalVariable(DbgNode).Verify() || DIFile(DbgNode).Verify() ||
DICompileUnit(DbgNode).Verify() || DINameSpace(DbgNode).Verify() ||
DILexicalBlock(DbgNode).Verify() ||
DILexicalBlockFile(DbgNode).Verify() ||
DISubrange(DbgNode).Verify() || DIEnumerator(DbgNode).Verify() ||
DIObjCProperty(DbgNode).Verify() ||
DITemplateTypeParameter(DbgNode).Verify() ||
DITemplateValueParameter(DbgNode).Verify() ||
DIImportedEntity(DbgNode).Verify());
}
static Metadata *getField(const MDNode *DbgNode, unsigned Elt) {
if (!DbgNode || Elt >= DbgNode->getNumOperands())
return nullptr;
@ -175,9 +159,6 @@ void DIDescriptor::replaceAllUsesWith(MDNode *D) {
Node->replaceAllUsesWith(D);
}
bool DICompileUnit::Verify() const { return isCompileUnit(); }
bool DIObjCProperty::Verify() const { return isObjCProperty(); }
#ifndef NDEBUG
/// \brief Check if a value can be a reference to a type.
static bool isTypeRef(const Metadata *MD) {
@ -207,43 +188,6 @@ static bool isDescriptorRef(const Metadata *MD) {
}
#endif
bool DIType::Verify() const { return isType(); }
bool DIBasicType::Verify() const { return isBasicType(); }
bool DIDerivedType::Verify() const { return isDerivedType(); }
bool DICompositeType::Verify() const { return isCompositeType(); }
bool DISubprogram::Verify() const { return isSubprogram(); }
bool DIGlobalVariable::Verify() const { return isGlobalVariable(); }
bool DIVariable::Verify() const { return isVariable(); }
bool DILocation::Verify() const {
return dyn_cast_or_null<MDLocation>(DbgNode);
}
bool DINameSpace::Verify() const {
return dyn_cast_or_null<MDNamespace>(DbgNode);
}
bool DIFile::Verify() const { return dyn_cast_or_null<MDFile>(DbgNode); }
bool DIEnumerator::Verify() const {
return dyn_cast_or_null<MDEnumerator>(DbgNode);
}
bool DISubrange::Verify() const {
return dyn_cast_or_null<MDSubrange>(DbgNode);
}
bool DILexicalBlock::Verify() const {
return dyn_cast_or_null<MDLexicalBlock>(DbgNode);
}
bool DILexicalBlockFile::Verify() const {
return dyn_cast_or_null<MDLexicalBlockFile>(DbgNode);
}
bool DITemplateTypeParameter::Verify() const {
return dyn_cast_or_null<MDTemplateTypeParameter>(DbgNode);
}
bool DITemplateValueParameter::Verify() const {
return dyn_cast_or_null<MDTemplateValueParameter>(DbgNode);
}
bool DIImportedEntity::Verify() const {
return dyn_cast_or_null<MDImportedEntity>(DbgNode);
}
void DICompositeType::setArraysHelper(MDNode *Elements, MDNode *TParams) {
TypedTrackingMDRef<MDCompositeTypeBase> N(get());
if (Elements)
@ -342,18 +286,15 @@ StringRef DIScope::getDirectory() const {
}
void DICompileUnit::replaceSubprograms(DIArray Subprograms) {
assert(Verify() && "Expected compile unit");
get()->replaceSubprograms(cast_or_null<MDTuple>(Subprograms.get()));
}
void DICompileUnit::replaceGlobalVariables(DIArray GlobalVariables) {
assert(Verify() && "Expected compile unit");
get()->replaceGlobalVariables(cast_or_null<MDTuple>(GlobalVariables.get()));
}
DILocation DILocation::copyWithNewScope(LLVMContext &Ctx,
DILexicalBlockFile NewScope) {
assert(Verify());
assert(NewScope && "Expected valid scope");
const auto *Old = cast<MDLocation>(DbgNode);
@ -368,13 +309,11 @@ unsigned DILocation::computeNewDiscriminator(LLVMContext &Ctx) {
DIVariable llvm::createInlinedVariable(MDNode *DV, MDNode *InlinedScope,
LLVMContext &VMContext) {
assert(DIVariable(DV).Verify() && "Expected a DIVariable");
return cast<MDLocalVariable>(DV)
->withInline(cast_or_null<MDLocation>(InlinedScope));
}
DIVariable llvm::cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext) {
assert(DIVariable(DV).Verify() && "Expected a DIVariable");
return cast<MDLocalVariable>(DV)->withoutInline();
}

View File

@ -306,14 +306,11 @@ bool StripDeadDebugInfo::runOnModule(Module &M) {
DenseSet<const MDNode *> VisitedSet;
for (DICompileUnit DIC : F.compile_units()) {
assert(DIC.Verify() && "DIC must verify as a DICompileUnit.");
// Create our live subprogram list.
DIArray SPs = DIC.getSubprograms();
bool SubprogramChange = false;
for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i) {
DISubprogram DISP(SPs.getElement(i));
assert(DISP.Verify() && "DISP must verify as a DISubprogram.");
// Make sure we visit each subprogram only once.
if (!VisitedSet.insert(DISP).second)
@ -331,7 +328,6 @@ bool StripDeadDebugInfo::runOnModule(Module &M) {
bool GlobalVariableChange = false;
for (unsigned i = 0, e = GVs.getNumElements(); i != e; ++i) {
DIGlobalVariable DIG(GVs.getElement(i));
assert(DIG.Verify() && "DIG must verify as DIGlobalVariable.");
// Make sure we only visit each global variable only once.
if (!VisitedSet.insert(DIG).second)

View File

@ -296,9 +296,7 @@ TEST_F(IRBuilderTest, DIBuilder) {
auto CU = DIB.createCompileUnit(dwarf::DW_LANG_Cobol74, "F.CBL", "/",
"llvm-cobol74", true, "", 0);
auto Type = DIB.createSubroutineType(File, DIB.getOrCreateTypeArray(None));
auto SP = DIB.createFunction(CU, "foo", "", File, 1, Type,
false, true, 1, 0, true, F);
EXPECT_TRUE(SP.Verify());
DIB.createFunction(CU, "foo", "", File, 1, Type, false, true, 1, 0, true, F);
AllocaInst *I = Builder.CreateAlloca(Builder.getInt8Ty());
auto BarSP = DIB.createFunction(CU, "bar", "", File, 1, Type, false, true, 1,
0, true, nullptr);