3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-12-12 14:46:23 +00:00

Forbid creating IdStrings and incrementing autoidx during multithreaded phases, and add dynamic checks for that

We could make it safe to increment autoidx during multithreaded passes, but that's
actually undesirable because it would lead to nondeterminism. If/when we need new
IDs during parallel passes, we'll have to figure out how to allocate them in a
deterministic way, and that will depend on the details of what the pass does.
So don't try to tackle that now.
This commit is contained in:
Robert O'Callahan 2025-11-24 22:29:06 +00:00
parent 4c8b537d71
commit 8f0ecce53f
5 changed files with 55 additions and 4 deletions

View file

@ -267,7 +267,30 @@ int ceil_log2(int x) YS_ATTRIBUTE(const);
template<typename T> int GetSize(const T &obj) { return obj.size(); }
inline int GetSize(RTLIL::Wire *wire);
extern int autoidx;
// When multiple threads are accessing RTLIL, one of these guard objects
// must exist.
struct Multithreading
{
Multithreading();
~Multithreading();
// Returns true when multiple threads are accessing RTLIL.
// autoidx cannot be used during such times.
// IdStrings cannot be created during such times.
static bool active() { return active_; }
private:
static bool active_;
};
struct Autoidx {
Autoidx(int value) : value(value) {}
operator int() const { return value; }
void ensure_at_least(int v);
int operator++(int);
private:
int value;
};
extern Autoidx autoidx;
extern int yosys_xtrace;
extern bool yosys_write_versions;