From 5fbd2a18b57e13fa76c204b10e5df12e13f895af Mon Sep 17 00:00:00 2001 From: James Cherry Date: Mon, 16 Mar 2026 14:53:02 -0700 Subject: [PATCH] Graph::slew/arcDelay rm static Signed-off-by: James Cherry --- dcalc/GraphDelayCalc.cc | 16 ++++++++-------- graph/Graph.cc | 30 ++++++++++-------------------- include/sta/Graph.hh | 22 +++++++++++----------- include/sta/Path.hh | 2 +- include/sta/Sta.hh | 6 +++--- search/Path.cc | 2 +- search/Sta.cc | 2 +- tcl/Util.tcl | 1 + 8 files changed, 36 insertions(+), 45 deletions(-) diff --git a/dcalc/GraphDelayCalc.cc b/dcalc/GraphDelayCalc.cc index 10c64e93..9d4cd733 100644 --- a/dcalc/GraphDelayCalc.cc +++ b/dcalc/GraphDelayCalc.cc @@ -504,7 +504,7 @@ GraphDelayCalc::seedNoDrvrSlew(Vertex *drvr_vertex, ArcDelayCalc *arc_delay_calc) { DcalcAPIndex ap_index = scene->dcalcAnalysisPtIndex(min_max); - Slew slew(default_slew); + Slew slew = default_slew; // Top level bidirect driver uses load slew unless // bidirect instance paths are disabled. if (bidirectDrvrSlewFromLoad(drvr_pin)) { @@ -744,7 +744,7 @@ GraphDelayCalc::loadSlewsChanged(DrvrLoadSlews &load_slews_prev, Vertex *load_vertex = graph_->pinLoadVertex(pin); SlewSeq &slews_prev = load_slews_prev[index];; for (size_t i = 0; i < slew_count; i++) { - const Slew &slew = graph_->slew(load_vertex, i); + const Slew slew = graph_->slew(load_vertex, i); if (!delayEqual(slew, slews_prev[i], this)) return true; } @@ -1216,13 +1216,13 @@ GraphDelayCalc::annotateDelaySlew(Edge *edge, Vertex *drvr_vertex = edge->to(graph_); const RiseFall *drvr_rf = arc->toEdge()->asRiseFall(); // Merge slews. - const Slew &drvr_slew = graph_->slew(drvr_vertex, drvr_rf, ap_index); + const Slew drvr_slew = graph_->slew(drvr_vertex, drvr_rf, ap_index); if (delayGreater(gate_slew, drvr_slew, min_max, this) && !drvr_vertex->slewAnnotated(drvr_rf, min_max) && !edge->role()->isLatchDtoQ()) graph_->setSlew(drvr_vertex, drvr_rf, ap_index, gate_slew); if (!graph_->arcDelayAnnotated(edge, arc, ap_index)) { - const ArcDelay &prev_gate_delay = graph_->arcDelay(edge,arc,ap_index); + const ArcDelay prev_gate_delay = graph_->arcDelay(edge,arc,ap_index); float gate_delay1 = delayAsFloat(gate_delay); float prev_gate_delay1 = delayAsFloat(prev_gate_delay); if (prev_gate_delay1 == 0.0 @@ -1267,12 +1267,12 @@ GraphDelayCalc::annotateLoadDelays(Vertex *drvr_vertex, if (!load_vertex->slewAnnotated(drvr_rf, min_max)) { if (drvr_vertex->slewAnnotated(drvr_rf, min_max)) { // Copy the driver slew to the load if it is annotated. - const Slew &drvr_slew = graph_->slew(drvr_vertex,drvr_rf,ap_index); + const Slew drvr_slew = graph_->slew(drvr_vertex,drvr_rf,ap_index); graph_->setSlew(load_vertex, drvr_rf, ap_index, drvr_slew); load_changed = true; } else { - const Slew &slew = graph_->slew(load_vertex, drvr_rf, ap_index); + const Slew slew = graph_->slew(load_vertex, drvr_rf, ap_index); if (!merge || delayGreater(load_slew, slew, min_max, this)) { graph_->setSlew(load_vertex, drvr_rf, ap_index, load_slew); @@ -1600,7 +1600,7 @@ GraphDelayCalc::findCheckEdgeDelays(Edge *edge, if (!graph_->arcDelayAnnotated(edge, arc, ap_index)) { const Slew &from_slew = checkEdgeClkSlew(from_vertex, from_rf, scene, min_max); - const Slew &to_slew = graph_->slew(to_vertex, to_rf, ap_index); + const Slew to_slew = graph_->slew(to_vertex, to_rf, ap_index); debugPrint(debug_, "delay_calc", 3, " %s %s -> %s %s (%s) scene:%s/%s", arc_set->from()->name(), @@ -1682,7 +1682,7 @@ GraphDelayCalc::reportDelayCalc(const Edge *edge, if (role->isTimingCheck()) { const Slew &from_slew = checkEdgeClkSlew(from_vertex, from_rf, scene, min_max); DcalcAPIndex slew_index = scene->dcalcAnalysisPtIndex(min_max); - const Slew &to_slew = graph_->slew(to_vertex, to_rf, slew_index); + const Slew to_slew = graph_->slew(to_vertex, to_rf, slew_index); const ClkNetwork *clk_network = scene->mode()->clkNetwork(); bool from_ideal_clk = clk_network->isIdealClock(from_vertex); const char *from_slew_annotation = from_ideal_clk ? " (ideal clock)" : nullptr; diff --git a/graph/Graph.cc b/graph/Graph.cc index e0c2102d..9878c6ac 100644 --- a/graph/Graph.cc +++ b/graph/Graph.cc @@ -577,7 +577,7 @@ Graph::gateEdgeArc(const Pin *in_pin, //////////////////////////////////////////////////////////////// -const Slew & +Slew Graph::slew(const Vertex *vertex, const RiseFall *rf, DcalcAPIndex ap_index) @@ -588,14 +588,11 @@ Graph::slew(const Vertex *vertex, const Slew *slews = std::bit_cast(slews_flt); return slews[slew_index]; } - else { - static Slew slew; - slew = slews_flt[slew_index]; - return slew; - } + else + return slews_flt[slew_index]; } -const Slew & +Slew Graph::slew(const Vertex *vertex, size_t index) { @@ -604,11 +601,8 @@ Graph::slew(const Vertex *vertex, const Slew *slews = std::bit_cast(slews_flt); return slews[index]; } - else { - static Slew slew; - slew = slews_flt[index]; - return slew; - } + else + return slews_flt[index]; } void @@ -677,7 +671,7 @@ Graph::deleteEdge(Edge *edge) edges_->destroy(edge); } -const ArcDelay & +ArcDelay Graph::arcDelay(const Edge *edge, const TimingArc *arc, DcalcAPIndex ap_index) const @@ -689,9 +683,7 @@ Graph::arcDelay(const Edge *edge, } else { const float *delays = edge->arcDelays(); - static ArcDelay delay; - delay = delays[index]; - return delay; + return delays[index]; } } @@ -712,7 +704,7 @@ Graph::setArcDelay(Edge *edge, } } -const ArcDelay & +ArcDelay Graph::wireArcDelay(const Edge *edge, const RiseFall *rf, DcalcAPIndex ap_index) @@ -724,9 +716,7 @@ Graph::wireArcDelay(const Edge *edge, } else { const float *delays = edge->arcDelays(); - static ArcDelay delay; - delay = delays[index]; - return delay; + return delays[index]; } } diff --git a/include/sta/Graph.hh b/include/sta/Graph.hh index 18a50015..6846ae89 100644 --- a/include/sta/Graph.hh +++ b/include/sta/Graph.hh @@ -91,11 +91,11 @@ public: // Reported slew are the same as those in the liberty tables. // reported_slews = measured_slews / slew_derate_from_library // Measured slews are between slew_lower_threshold and slew_upper_threshold. - const Slew &slew(const Vertex *vertex, - const RiseFall *rf, - DcalcAPIndex ap_index); - const Slew &slew(const Vertex *vertex, - size_t index); + Slew slew(const Vertex *vertex, + const RiseFall *rf, + DcalcAPIndex ap_index); + Slew slew(const Vertex *vertex, + size_t index); void setSlew(Vertex *vertex, const RiseFall *rf, DcalcAPIndex ap_index, @@ -124,17 +124,17 @@ public: Edge *&edge, const TimingArc *&arc) const; - const ArcDelay &arcDelay(const Edge *edge, - const TimingArc *arc, - DcalcAPIndex ap_index) const; + ArcDelay arcDelay(const Edge *edge, + const TimingArc *arc, + DcalcAPIndex ap_index) const; void setArcDelay(Edge *edge, const TimingArc *arc, DcalcAPIndex ap_index, const ArcDelay &delay); // Alias for arcDelays using library wire arcs. - const ArcDelay &wireArcDelay(const Edge *edge, - const RiseFall *rf, - DcalcAPIndex ap_index); + ArcDelay wireArcDelay(const Edge *edge, + const RiseFall *rf, + DcalcAPIndex ap_index); void setWireArcDelay(Edge *edge, const RiseFall *rf, DcalcAPIndex ap_index, diff --git a/include/sta/Path.hh b/include/sta/Path.hh index c12c080b..7095a269 100644 --- a/include/sta/Path.hh +++ b/include/sta/Path.hh @@ -103,7 +103,7 @@ public: const Required &required() const {return required_; } void setRequired(const Required &required); Slack slack(const StaState *sta) const; - const Slew &slew(const StaState *sta) const; + const Slew slew(const StaState *sta) const; // This takes the same time as prevPath and prevArc combined. Path *prevPath() const; void setPrevPath(Path *prev_path); diff --git a/include/sta/Sta.hh b/include/sta/Sta.hh index 1464aa06..4c49b7f3 100644 --- a/include/sta/Sta.hh +++ b/include/sta/Sta.hh @@ -1142,9 +1142,9 @@ public: const SceneSeq &scenes, const MinMax *min_max); - const ArcDelay &arcDelay(Edge *edge, - TimingArc *arc, - DcalcAPIndex ap_index); + const ArcDelay arcDelay(Edge *edge, + TimingArc *arc, + DcalcAPIndex ap_index); // True if the timing arc has been back-annotated. bool arcDelayAnnotated(Edge *edge, TimingArc *arc, diff --git a/search/Path.cc b/search/Path.cc index 84b4764b..38470f8e 100644 --- a/search/Path.cc +++ b/search/Path.cc @@ -330,7 +330,7 @@ Path::pathAnalysisPtIndex(const StaState *sta) const return scene(sta)->pathIndex(minMax(sta)); } -const Slew & +const Slew Path::slew(const StaState *sta) const { DcalcAPIndex slew_index = scene(sta)->dcalcAnalysisPtIndex(minMax(sta)); diff --git a/search/Sta.cc b/search/Sta.cc index e8fe636c..d5d58bbb 100644 --- a/search/Sta.cc +++ b/search/Sta.cc @@ -3622,7 +3622,7 @@ Sta::setIncrementalDelayTolerance(float tol) graph_delay_calc_->setIncrementalDelayTolerance(tol); } -const ArcDelay& +const ArcDelay Sta::arcDelay(Edge *edge, TimingArc *arc, DcalcAPIndex ap_index) diff --git a/tcl/Util.tcl b/tcl/Util.tcl index 15443529..3236cb93 100644 --- a/tcl/Util.tcl +++ b/tcl/Util.tcl @@ -267,6 +267,7 @@ define_cmd_args "user_run_time" {} # Write run time statistics to filename. proc write_stats { filename } { +puts "stats $filename" if { ![catch {open $filename w} stream] } { puts $stream "[elapsed_run_time] [user_run_time] [memory_usage]" close $stream