mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-11-03 21:09:12 +00:00 
			
		
		
		
	passes: opt_share: don't statically initialize mergeable_type_map
In 3d3779b037 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>
			
			
This commit is contained in:
		
							parent
							
								
									417f3fe6b1
								
							
						
					
					
						commit
						8d128ba6d0
					
				
					 1 changed files with 4 additions and 3 deletions
				
			
		| 
						 | 
					@ -108,12 +108,13 @@ bool cell_supported(RTLIL::Cell *cell)
 | 
				
			||||||
	return false;
 | 
						return false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
std::map<IdString, IdString> mergeable_type_map{
 | 
					std::map<IdString, IdString> mergeable_type_map;
 | 
				
			||||||
  {ID($sub), ID($add)},
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool mergeable(RTLIL::Cell *a, RTLIL::Cell *b)
 | 
					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;
 | 
						auto a_type = a->type;
 | 
				
			||||||
	if (mergeable_type_map.count(a_type))
 | 
						if (mergeable_type_map.count(a_type))
 | 
				
			||||||
		a_type = mergeable_type_map.at(a_type);
 | 
							a_type = mergeable_type_map.at(a_type);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue