mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 01:54:01 +02:00
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:
+6
-6
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user