mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-26 10:29:36 +00:00
verify-di: split out VerifierSupport
Split out assertion and output helpers from Verifier in preparation for writing the DebugInfoVerifier. <rdar://problem/15500563> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206299 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3549f3cf19
commit
abf483ba52
@ -79,11 +79,68 @@ using namespace llvm;
|
|||||||
static cl::opt<bool> VerifyDebugInfo("verify-debug-info", cl::init(false));
|
static cl::opt<bool> VerifyDebugInfo("verify-debug-info", cl::init(false));
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
class Verifier : public InstVisitor<Verifier> {
|
struct VerifierSupport {
|
||||||
friend class InstVisitor<Verifier>;
|
|
||||||
|
|
||||||
raw_ostream &OS;
|
raw_ostream &OS;
|
||||||
const Module *M;
|
const Module *M;
|
||||||
|
|
||||||
|
/// \brief Track the brokenness of the module while recursively visiting.
|
||||||
|
bool Broken;
|
||||||
|
|
||||||
|
explicit VerifierSupport(raw_ostream &OS)
|
||||||
|
: OS(OS), M(nullptr), Broken(false) {}
|
||||||
|
|
||||||
|
void WriteValue(const Value *V) {
|
||||||
|
if (!V)
|
||||||
|
return;
|
||||||
|
if (isa<Instruction>(V)) {
|
||||||
|
OS << *V << '\n';
|
||||||
|
} else {
|
||||||
|
V->printAsOperand(OS, true, M);
|
||||||
|
OS << '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WriteType(Type *T) {
|
||||||
|
if (!T)
|
||||||
|
return;
|
||||||
|
OS << ' ' << *T;
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckFailed - A check failed, so print out the condition and the message
|
||||||
|
// that failed. This provides a nice place to put a breakpoint if you want
|
||||||
|
// to see why something is not correct.
|
||||||
|
void CheckFailed(const Twine &Message, const Value *V1 = nullptr,
|
||||||
|
const Value *V2 = nullptr, const Value *V3 = nullptr,
|
||||||
|
const Value *V4 = nullptr) {
|
||||||
|
OS << Message.str() << "\n";
|
||||||
|
WriteValue(V1);
|
||||||
|
WriteValue(V2);
|
||||||
|
WriteValue(V3);
|
||||||
|
WriteValue(V4);
|
||||||
|
Broken = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CheckFailed(const Twine &Message, const Value *V1, Type *T2,
|
||||||
|
const Value *V3 = nullptr) {
|
||||||
|
OS << Message.str() << "\n";
|
||||||
|
WriteValue(V1);
|
||||||
|
WriteType(T2);
|
||||||
|
WriteValue(V3);
|
||||||
|
Broken = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CheckFailed(const Twine &Message, Type *T1, Type *T2 = nullptr,
|
||||||
|
Type *T3 = nullptr) {
|
||||||
|
OS << Message.str() << "\n";
|
||||||
|
WriteType(T1);
|
||||||
|
WriteType(T2);
|
||||||
|
WriteType(T3);
|
||||||
|
Broken = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
class Verifier : public InstVisitor<Verifier>, VerifierSupport {
|
||||||
|
friend class InstVisitor<Verifier>;
|
||||||
|
|
||||||
LLVMContext *Context;
|
LLVMContext *Context;
|
||||||
const DataLayout *DL;
|
const DataLayout *DL;
|
||||||
DominatorTree DT;
|
DominatorTree DT;
|
||||||
@ -106,13 +163,10 @@ class Verifier : public InstVisitor<Verifier> {
|
|||||||
/// \brief Finder keeps track of all debug info MDNodes in a Module.
|
/// \brief Finder keeps track of all debug info MDNodes in a Module.
|
||||||
DebugInfoFinder Finder;
|
DebugInfoFinder Finder;
|
||||||
|
|
||||||
/// \brief Track the brokenness of the module while recursively visiting.
|
|
||||||
bool Broken;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Verifier(raw_ostream &OS = dbgs())
|
explicit Verifier(raw_ostream &OS = dbgs())
|
||||||
: OS(OS), M(nullptr), Context(nullptr), DL(nullptr),
|
: VerifierSupport(OS), Context(nullptr), DL(nullptr),
|
||||||
PersonalityFn(nullptr), Broken(false) {}
|
PersonalityFn(nullptr) {}
|
||||||
|
|
||||||
bool verify(const Function &F) {
|
bool verify(const Function &F) {
|
||||||
M = F.getParent();
|
M = F.getParent();
|
||||||
@ -280,55 +334,6 @@ private:
|
|||||||
void VerifyConstantExprBitcastType(const ConstantExpr *CE);
|
void VerifyConstantExprBitcastType(const ConstantExpr *CE);
|
||||||
|
|
||||||
void verifyDebugInfo();
|
void verifyDebugInfo();
|
||||||
|
|
||||||
void WriteValue(const Value *V) {
|
|
||||||
if (!V)
|
|
||||||
return;
|
|
||||||
if (isa<Instruction>(V)) {
|
|
||||||
OS << *V << '\n';
|
|
||||||
} else {
|
|
||||||
V->printAsOperand(OS, true, M);
|
|
||||||
OS << '\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void WriteType(Type *T) {
|
|
||||||
if (!T)
|
|
||||||
return;
|
|
||||||
OS << ' ' << *T;
|
|
||||||
}
|
|
||||||
|
|
||||||
// CheckFailed - A check failed, so print out the condition and the message
|
|
||||||
// that failed. This provides a nice place to put a breakpoint if you want
|
|
||||||
// to see why something is not correct.
|
|
||||||
void CheckFailed(const Twine &Message, const Value *V1 = nullptr,
|
|
||||||
const Value *V2 = nullptr, const Value *V3 = nullptr,
|
|
||||||
const Value *V4 = nullptr) {
|
|
||||||
OS << Message.str() << "\n";
|
|
||||||
WriteValue(V1);
|
|
||||||
WriteValue(V2);
|
|
||||||
WriteValue(V3);
|
|
||||||
WriteValue(V4);
|
|
||||||
Broken = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CheckFailed(const Twine &Message, const Value *V1, Type *T2,
|
|
||||||
const Value *V3 = nullptr) {
|
|
||||||
OS << Message.str() << "\n";
|
|
||||||
WriteValue(V1);
|
|
||||||
WriteType(T2);
|
|
||||||
WriteValue(V3);
|
|
||||||
Broken = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CheckFailed(const Twine &Message, Type *T1, Type *T2 = nullptr,
|
|
||||||
Type *T3 = nullptr) {
|
|
||||||
OS << Message.str() << "\n";
|
|
||||||
WriteType(T1);
|
|
||||||
WriteType(T2);
|
|
||||||
WriteType(T3);
|
|
||||||
Broken = true;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
} // End anonymous namespace
|
} // End anonymous namespace
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user