mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-12-25 17:21:06 +00:00
DefUseManager: rename comparison operators to 'CompareAndPrintDifferences' (#4624)
This make sense, as those are actually debug functions and shouldn't be used in production code.
This commit is contained in:
parent
f37551d2b6
commit
b9e255b366
@ -259,49 +259,53 @@ void DefUseManager::EraseUseRecordsOfOperandIds(const Instruction* inst) {
|
||||
}
|
||||
}
|
||||
|
||||
bool operator==(const DefUseManager& lhs, const DefUseManager& rhs) {
|
||||
bool CompareAndPrintDifferences(const DefUseManager& lhs,
|
||||
const DefUseManager& rhs) {
|
||||
bool same = true;
|
||||
|
||||
if (lhs.id_to_def_ != rhs.id_to_def_) {
|
||||
for (auto p : lhs.id_to_def_) {
|
||||
if (rhs.id_to_def_.find(p.first) == rhs.id_to_def_.end()) {
|
||||
return false;
|
||||
printf("Diff in id_to_def: missing value in rhs\n");
|
||||
}
|
||||
}
|
||||
for (auto p : rhs.id_to_def_) {
|
||||
if (lhs.id_to_def_.find(p.first) == lhs.id_to_def_.end()) {
|
||||
return false;
|
||||
printf("Diff in id_to_def: missing value in lhs\n");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
same = false;
|
||||
}
|
||||
|
||||
if (lhs.id_to_users_ != rhs.id_to_users_) {
|
||||
for (auto p : lhs.id_to_users_) {
|
||||
if (rhs.id_to_users_.count(p) == 0) {
|
||||
return false;
|
||||
printf("Diff in id_to_users: missing value in rhs\n");
|
||||
}
|
||||
}
|
||||
for (auto p : rhs.id_to_users_) {
|
||||
if (lhs.id_to_users_.count(p) == 0) {
|
||||
return false;
|
||||
printf("Diff in id_to_users: missing value in lhs\n");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
same = false;
|
||||
}
|
||||
|
||||
if (lhs.inst_to_used_ids_ != rhs.inst_to_used_ids_) {
|
||||
for (auto p : lhs.inst_to_used_ids_) {
|
||||
if (rhs.inst_to_used_ids_.count(p.first) == 0) {
|
||||
return false;
|
||||
printf("Diff in inst_to_used_ids: missing value in rhs\n");
|
||||
}
|
||||
}
|
||||
for (auto p : rhs.inst_to_used_ids_) {
|
||||
if (lhs.inst_to_used_ids_.count(p.first) == 0) {
|
||||
return false;
|
||||
printf("Diff in inst_to_used_ids: missing value in lhs\n");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
same = false;
|
||||
}
|
||||
return true;
|
||||
|
||||
return same;
|
||||
}
|
||||
|
||||
} // namespace analysis
|
||||
|
@ -210,10 +210,8 @@ class DefUseManager {
|
||||
// Erases the records that a given instruction uses its operand ids.
|
||||
void EraseUseRecordsOfOperandIds(const Instruction* inst);
|
||||
|
||||
friend bool operator==(const DefUseManager&, const DefUseManager&);
|
||||
friend bool operator!=(const DefUseManager& lhs, const DefUseManager& rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
friend bool CompareAndPrintDifferences(const DefUseManager&,
|
||||
const DefUseManager&);
|
||||
|
||||
// If |inst| has not already been analysed, then analyses its defintion and
|
||||
// uses.
|
||||
|
@ -317,7 +317,7 @@ bool IRContext::IsConsistent() {
|
||||
#else
|
||||
if (AreAnalysesValid(kAnalysisDefUse)) {
|
||||
analysis::DefUseManager new_def_use(module());
|
||||
if (*get_def_use_mgr() != new_def_use) {
|
||||
if (!CompareAndPrintDifferences(*get_def_use_mgr(), new_def_use)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user