mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 01:54:01 +02:00
Fix display optimization ignoring side effects (#4585).
This commit is contained in:
@@ -2132,6 +2132,8 @@ public:
|
||||
virtual bool isPredictOptimizable() const { return !isTimingControl(); }
|
||||
// Else a $display, etc, that must be ordered with other displays
|
||||
virtual bool isPure() { return true; }
|
||||
// Iff isPure on current node and any nextp()
|
||||
bool isPureAndNext() { return isPure() && (!nextp() || nextp()->isPure()); }
|
||||
// Else a AstTime etc that can't be substituted out
|
||||
virtual bool isSubstOptimizable() const { return true; }
|
||||
// An event control, delay, wait, etc.
|
||||
|
||||
@@ -3149,6 +3149,8 @@ private:
|
||||
// right line numbers, nor scopeNames as might be different scopes (late in process)
|
||||
if (!m_doCpp && pformatp->exprsp()) return false;
|
||||
if (!m_doCpp && nformatp->exprsp()) return false;
|
||||
if (pformatp->exprsp() && !pformatp->exprsp()->isPureAndNext()) return false;
|
||||
if (nformatp->exprsp() && !nformatp->exprsp()->isPureAndNext()) return false;
|
||||
// Avoid huge merges
|
||||
static constexpr int DISPLAY_MAX_MERGE_LENGTH = 500;
|
||||
if (pformatp->text().length() + nformatp->text().length() > DISPLAY_MAX_MERGE_LENGTH)
|
||||
|
||||
Reference in New Issue
Block a user