mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-08 19:25:47 +00:00
How to be dumb on $5/day. Need a tri-state to track valid debug descriptors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27154 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -773,16 +773,21 @@ public:
|
|||||||
/// GlobalVariables are valid as DebugInfoDesc objects.
|
/// GlobalVariables are valid as DebugInfoDesc objects.
|
||||||
class DIVerifier {
|
class DIVerifier {
|
||||||
private:
|
private:
|
||||||
|
enum {
|
||||||
|
Unknown = 0,
|
||||||
|
Invalid,
|
||||||
|
Valid
|
||||||
|
};
|
||||||
unsigned DebugVersion; // Version of debug information in use.
|
unsigned DebugVersion; // Version of debug information in use.
|
||||||
std::set<GlobalVariable *> Visited; // Tracks visits during recursion.
|
std::map<GlobalVariable *, unsigned> Validity;// Tracks prior results.
|
||||||
std::map<unsigned, unsigned> Counts; // Count of fields per Tag type.
|
std::map<unsigned, unsigned> Counts; // Count of fields per Tag type.
|
||||||
|
|
||||||
/// markVisited - Return true if the GlobalVariable hase been "seen" before.
|
|
||||||
/// Mark markVisited otherwise.
|
|
||||||
bool markVisited(GlobalVariable *GV);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DIVerifier() : DebugVersion(LLVMDebugVersion) {}
|
DIVerifier()
|
||||||
|
: DebugVersion(LLVMDebugVersion)
|
||||||
|
, Validity()
|
||||||
|
, Counts()
|
||||||
|
{}
|
||||||
~DIVerifier() {}
|
~DIVerifier() {}
|
||||||
|
|
||||||
/// Verify - Return true if the GlobalVariable appears to be a valid
|
/// Verify - Return true if the GlobalVariable appears to be a valid
|
||||||
|
@@ -1320,30 +1320,24 @@ GlobalVariable *DISerializer::Serialize(DebugInfoDesc *DD) {
|
|||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
/// markVisited - Return true if the GlobalVariable hase been "seen" before.
|
|
||||||
/// Mark visited otherwise.
|
|
||||||
bool DIVerifier::markVisited(GlobalVariable *GV) {
|
|
||||||
// Check if the GlobalVariable is already in the Visited set.
|
|
||||||
std::set<GlobalVariable *>::iterator VI = Visited.lower_bound(GV);
|
|
||||||
|
|
||||||
// See if GlobalVariable exists.
|
|
||||||
bool Exists = VI != Visited.end() && *VI == GV;
|
|
||||||
|
|
||||||
// Insert in set.
|
|
||||||
if (!Exists) Visited.insert(VI, GV);
|
|
||||||
|
|
||||||
return Exists;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Verify - Return true if the GlobalVariable appears to be a valid
|
/// Verify - Return true if the GlobalVariable appears to be a valid
|
||||||
/// serialization of a DebugInfoDesc.
|
/// serialization of a DebugInfoDesc.
|
||||||
bool DIVerifier::Verify(Value *V) {
|
bool DIVerifier::Verify(Value *V) {
|
||||||
return Verify(getGlobalVariable(V));
|
return Verify(getGlobalVariable(V));
|
||||||
}
|
}
|
||||||
bool DIVerifier::Verify(GlobalVariable *GV) {
|
bool DIVerifier::Verify(GlobalVariable *GV) {
|
||||||
// Check if seen before.
|
// NULLs are valid.
|
||||||
if (markVisited(GV)) return true;
|
if (!GV) return true;
|
||||||
|
|
||||||
|
// Check prior validity.
|
||||||
|
unsigned &ValiditySlot = Validity[GV];
|
||||||
|
|
||||||
|
// If visited before then use old state.
|
||||||
|
if (ValiditySlot) return ValiditySlot == Valid;
|
||||||
|
|
||||||
|
// Assume validity for the time being (recursion.)
|
||||||
|
ValiditySlot = Valid;
|
||||||
|
|
||||||
// Get the Tag
|
// Get the Tag
|
||||||
unsigned Tag = DebugInfoDesc::TagFromGlobal(GV);
|
unsigned Tag = DebugInfoDesc::TagFromGlobal(GV);
|
||||||
|
|
||||||
@@ -1354,7 +1348,10 @@ bool DIVerifier::Verify(GlobalVariable *GV) {
|
|||||||
if (Tag == DW_TAG_compile_unit) {
|
if (Tag == DW_TAG_compile_unit) {
|
||||||
DebugVersion = CompileUnitDesc::DebugVersionFromGlobal(GV);
|
DebugVersion = CompileUnitDesc::DebugVersionFromGlobal(GV);
|
||||||
// FIXME - In the short term, changes are too drastic to continue.
|
// FIXME - In the short term, changes are too drastic to continue.
|
||||||
if (DebugVersion != LLVMDebugVersion) return false;
|
if (DebugVersion != LLVMDebugVersion) {
|
||||||
|
ValiditySlot = Invalid;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct an empty DebugInfoDesc.
|
// Construct an empty DebugInfoDesc.
|
||||||
@@ -1370,17 +1367,18 @@ bool DIVerifier::Verify(GlobalVariable *GV) {
|
|||||||
unsigned N = CI->getNumOperands();
|
unsigned N = CI->getNumOperands();
|
||||||
|
|
||||||
// Get the field count.
|
// Get the field count.
|
||||||
unsigned &Slot = Counts[Tag];
|
unsigned &CountSlot = Counts[Tag];
|
||||||
if (!Slot) {
|
if (!CountSlot) {
|
||||||
// Check the operand count to the field count
|
// Check the operand count to the field count
|
||||||
DICountVisitor CTAM;
|
DICountVisitor CTAM;
|
||||||
CTAM.ApplyToFields(DD);
|
CTAM.ApplyToFields(DD);
|
||||||
Slot = CTAM.getCount();
|
CountSlot = CTAM.getCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field count must be at most equal operand count.
|
// Field count must be at most equal operand count.
|
||||||
if (Slot > N) {
|
if (CountSlot > N) {
|
||||||
delete DD;
|
delete DD;
|
||||||
|
ValiditySlot = Invalid;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1391,8 +1389,13 @@ bool DIVerifier::Verify(GlobalVariable *GV) {
|
|||||||
// Release empty DebugInfoDesc.
|
// Release empty DebugInfoDesc.
|
||||||
delete DD;
|
delete DD;
|
||||||
|
|
||||||
// Return result of field tests.
|
// If fields are not valid.
|
||||||
return VRAM.isValid();
|
if (!VRAM.isValid()) {
|
||||||
|
ValiditySlot = Invalid;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
Reference in New Issue
Block a user