diff --git a/src/V3UndrivenCapture.cpp b/src/V3UndrivenCapture.cpp index ec6e23846..cd6d84c76 100644 --- a/src/V3UndrivenCapture.cpp +++ b/src/V3UndrivenCapture.cpp @@ -101,10 +101,10 @@ void V3UndrivenCapture::sortUniqueVars(std::vector& vec) { vec.erase(std::unique(vec.begin(), vec.end()), vec.end()); } -void V3UndrivenCapture::sortUniqueFTasks(std::vector& vec) { - std::sort(vec.begin(), vec.end()); - vec.erase(std::unique(vec.begin(), vec.end()), vec.end()); -} +//void V3UndrivenCapture::sortUniqueFTasks(std::vector& vec) { +// std::sort(vec.begin(), vec.end()); +// vec.erase(std::unique(vec.begin(), vec.end()), vec.end()); +//} V3UndrivenCapture::V3UndrivenCapture(AstNetlist* netlistp) { gather(netlistp); @@ -112,7 +112,7 @@ V3UndrivenCapture::V3UndrivenCapture(AstNetlist* netlistp) { // Normalize direct lists for (auto& kv : m_info) { sortUniqueVars(kv.second.directWrites); - sortUniqueFTasks(kv.second.callees); + //sortUniqueFTasks(kv.second.callees); } // Compute summaries for all tasks @@ -194,8 +194,13 @@ void V3UndrivenCapture::noteDirectWrite(const AstNodeFTask* taskp, AstVar* varp) } void V3UndrivenCapture::noteCallEdge(const AstNodeFTask* callerp, const AstNodeFTask* calleep) { - m_info[callerp].callees.push_back(calleep); - (void)m_info[calleep]; // ensure callee entry exists + //m_info[callerp].callees.push_back(calleep); + //(void)m_info[calleep]; // ensure callee entry exists + FTaskInfo& callerInfo = m_info[callerp]; + if (callerInfo.calleesSet.insert(calleep).second) { + callerInfo.callees.push_back(calleep); + } + (void)m_info[calleep]; } void V3UndrivenCapture::debugDumpTask(const AstNodeFTask* taskp, int level) const { diff --git a/src/V3UndrivenCapture.h b/src/V3UndrivenCapture.h index 3e0646c6b..d16e9e072 100644 --- a/src/V3UndrivenCapture.h +++ b/src/V3UndrivenCapture.h @@ -55,6 +55,9 @@ public: std::vector writeSummary; // State for writeSummary computation. State state = State::UNVISITED; + // This is used to test whether weve already recorded a callee. Used to 'filter' on insert + // versus sorting at the end. + std::unordered_set calleesSet; }; // Enable writeSummary computation. If disabled, then the existing V3Undriven behaviour is @@ -74,7 +77,7 @@ private: static void sortUniqueVars(std::vector& vec); // Sort and remove duplicates from a vector of callees. The visitor can record the same callee // multiple times (multiple call sites, branches, etc). - static void sortUniqueFTasks(std::vector& vec); + //static void sortUniqueFTasks(std::vector& vec); // Collect direct writes and call edges for all tasks/functions. Run one time when // UndrivenCapture is created. This runs the visitor over the tree.