Internals: Optimize temporary memory allocations (#6517)

This patch gets rid of over 80% of temporary dynamic memory allocations
(when a malloced node is immediately freed with no other malloc in
between). It also gets rid of over 20% of all calls to malloc.

It's worth ~3% average verilation speed up with tcmalloc, and more
without tcmalloc.
This commit is contained in:
Geza Lore
2025-10-01 15:01:30 +01:00
committed by GitHub
parent 435e1149d5
commit e9c48cd1ce
19 changed files with 218 additions and 216 deletions
+1 -1
View File
@@ -206,7 +206,7 @@ class LocalizeVisitor final : public VNVisitor {
AstVarScope* const varScopep = nodep->varScopep();
// Remember this function accesses this VarScope (we always need this as we might optimize
// this VarScope into a local, even if it's not assigned. See 'isOptimizable')
m_accessors(varScopep).emplace(m_cfuncp);
m_accessors(varScopep).insert(m_cfuncp); // emplace performs a temporary malloc
// Remember the reference so we can fix it up later (we always need this as well)
m_references(m_cfuncp).emplace(varScopep, nodep);