diff options
author | Sean Cross <sean@xobs.io> | 2019-09-09 12:40:01 +0800 |
---|---|---|
committer | Sean Cross <sean@xobs.io> | 2019-09-09 12:40:01 +0800 |
commit | 8d128ba6d079fd5f0741c31a9308bf06aaf4673c (patch) | |
tree | ac073ba260ffa5be96a5ee2a4904f3b76dc8c0c0 /passes/opt | |
parent | 417f3fe6b19a0ed36cabe526fe3c67214b32971d (diff) | |
download | yosys-8d128ba6d079fd5f0741c31a9308bf06aaf4673c.tar.gz yosys-8d128ba6d079fd5f0741c31a9308bf06aaf4673c.tar.bz2 yosys-8d128ba6d079fd5f0741c31a9308bf06aaf4673c.zip |
passes: opt_share: don't statically initialize mergeable_type_map
In 3d3779b0376b8204ed7637053176a07b7271ac1d this got turned from a
`std::map<std::string, std::string>` to `std::map<IdString, IdString>`.
Consequently, this exposed some initialization sequencing issues (#1361).
Only initialize the map when it's first used, to avoid these static issues.
This fixes #1361.
Signed-off-by: Sean Cross <sean@xobs.io>
Diffstat (limited to 'passes/opt')
-rw-r--r-- | passes/opt/opt_share.cc | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/passes/opt/opt_share.cc b/passes/opt/opt_share.cc index c53fb3113..2c456705c 100644 --- a/passes/opt/opt_share.cc +++ b/passes/opt/opt_share.cc @@ -108,12 +108,13 @@ bool cell_supported(RTLIL::Cell *cell) return false; } -std::map<IdString, IdString> mergeable_type_map{ - {ID($sub), ID($add)}, -}; +std::map<IdString, IdString> mergeable_type_map; bool mergeable(RTLIL::Cell *a, RTLIL::Cell *b) { + if (mergeable_type_map.empty()) { + mergeable_type_map.insert({ID($sub), ID($add)}); + } auto a_type = a->type; if (mergeable_type_map.count(a_type)) a_type = mergeable_type_map.at(a_type); |