Fix Dfg reusing volatile variables

Forceable/externally written variables cannot be used as the canonical
result variable for a Dfg value as the variables value can be
inconsistent with its Dfg drivers (e.g. when forced).
This commit is contained in:
Geza Lore
2025-12-05 14:12:36 +00:00
parent cfada791e6
commit df7726c40d
4 changed files with 90 additions and 7 deletions
+6 -6
View File
@@ -552,6 +552,10 @@ DfgVertexVar* DfgVertex::getResultVar() {
this->foreachSink([&resp](DfgVertex& sink) {
DfgVertexVar* const varp = sink.cast<DfgVertexVar>();
if (!varp) return false;
// Do not use it if value might differ from its drivers
if (varp->isVolatile()) return false;
// First variable found
if (!resp) {
resp = varp;
@@ -559,12 +563,8 @@ DfgVertexVar* DfgVertex::getResultVar() {
}
// Prefer those variables that must be kept anyway
if (resp->hasExtRefs() != varp->hasExtRefs()) {
if (!resp->hasExtRefs()) resp = varp;
return false;
}
if (resp->hasModWrRefs() != varp->hasModWrRefs()) {
if (!resp->hasModWrRefs()) resp = varp;
if (resp->hasExtRdRefs() != varp->hasExtRdRefs()) {
if (!resp->hasExtRdRefs()) resp = varp;
return false;
}
if (resp->hasDfgRefs() != varp->hasDfgRefs()) {