From 09e352ef6659638d28aeadd2d4ae9fe7cd0b9cd9 Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Tue, 27 Sep 2022 13:50:37 +0100 Subject: [PATCH] DFG: support hashing of graphs circular through variables No functional change --- src/V3Dfg.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/V3Dfg.cpp b/src/V3Dfg.cpp index 5350be82d..56e0a8290 100644 --- a/src/V3Dfg.cpp +++ b/src/V3Dfg.cpp @@ -468,7 +468,11 @@ V3Hash DfgVertex::hash(HashCache& cache) const { V3Hash& result = pair.first->second; if (pair.second) { result += selfHash(); - forEachSource([&result, &cache](const DfgVertex& src) { result += src.hash(cache); }); + // Variables are defined by themselves, so there is no need to hash the sources. This + // enables sound hashing of graphs circular only through variables, which we rely on. + if (!is()) { + forEachSource([&result, &cache](const DfgVertex& src) { result += src.hash(cache); }); + } } return result; } @@ -503,9 +507,8 @@ void DfgVar::accept(DfgVisitor& visitor) { visitor.visit(this); } bool DfgVar::selfEquals(const DfgVertex& that) const { if (const DfgVar* otherp = that.cast()) { - UASSERT_OBJ(varp() != otherp->varp() || this == otherp, this, + UASSERT_OBJ(varp() != otherp->varp(), this, "There should only be one DfgVar for a given AstVar"); - return this == otherp; } return false; }