Fix a nondeterminism issue in the new V3Split

This commit is contained in:
John Coiner 2018-03-29 14:03:18 -04:00
parent 1f04d17e77
commit 422c915c1d

View File

@ -627,7 +627,7 @@ private:
}; };
typedef vl_unordered_set<uint32_t> ColorSet; typedef vl_unordered_set<uint32_t> ColorSet;
typedef vl_unordered_set<AstAlways*> AlwaysSet; typedef std::vector<AstAlways*> AlwaysVec;
class IfColorVisitor : public AstNVisitor { class IfColorVisitor : public AstNVisitor {
// MEMBERS // MEMBERS
@ -714,7 +714,7 @@ class EmitSplitVisitor : public AstNVisitor {
typedef vl_unordered_map<uint32_t, AstNode*> LocMap; typedef vl_unordered_map<uint32_t, AstNode*> LocMap;
LocMap m_addAfter; LocMap m_addAfter;
AlwaysSet* m_newBlocksp; // Split always blocks we have generated AlwaysVec* m_newBlocksp; // Split always blocks we have generated
// CONSTRUCTORS // CONSTRUCTORS
public: public:
@ -723,7 +723,7 @@ public:
// into *newBlocksp. // into *newBlocksp.
EmitSplitVisitor(AstAlways* nodep, EmitSplitVisitor(AstAlways* nodep,
const IfColorVisitor* ifColorp, const IfColorVisitor* ifColorp,
AlwaysSet* newBlocksp) AlwaysVec* newBlocksp)
: m_origAlwaysp(nodep) : m_origAlwaysp(nodep)
, m_ifColorp(ifColorp) , m_ifColorp(ifColorp)
, m_newBlocksp(newBlocksp) { , m_newBlocksp(newBlocksp) {
@ -748,7 +748,7 @@ public:
AstSplitPlaceholder* placeholderp = makePlaceholderp(); AstSplitPlaceholder* placeholderp = makePlaceholderp();
alwaysp->addStmtp(placeholderp); alwaysp->addStmtp(placeholderp);
m_addAfter[*color] = placeholderp; m_addAfter[*color] = placeholderp;
m_newBlocksp->insert(alwaysp); m_newBlocksp->push_back(alwaysp);
} }
// Scan the body of the always. We'll handle if/else // Scan the body of the always. We'll handle if/else
// specially, everything else is a leaf node that we can // specially, everything else is a leaf node that we can
@ -861,7 +861,7 @@ private:
// Keys are original always blocks pending delete, // Keys are original always blocks pending delete,
// values are newly split always blocks pending insertion // values are newly split always blocks pending insertion
// at the same position as the originals: // at the same position as the originals:
typedef vl_unordered_map<AstAlways*, AlwaysSet> ReplaceMap; typedef vl_unordered_map<AstAlways*, AlwaysVec> ReplaceMap;
ReplaceMap m_replaceBlocks; ReplaceMap m_replaceBlocks;
// AstNodeIf* whose condition we're currently visiting // AstNodeIf* whose condition we're currently visiting
@ -880,7 +880,7 @@ public:
for (ReplaceMap::iterator it = m_replaceBlocks.begin(); for (ReplaceMap::iterator it = m_replaceBlocks.begin();
it != m_replaceBlocks.end(); ++it) { it != m_replaceBlocks.end(); ++it) {
AstAlways* origp = it->first; AstAlways* origp = it->first;
for (AlwaysSet::iterator addme = it->second.begin(); for (AlwaysVec::iterator addme = it->second.begin();
addme != it->second.end(); ++addme) { addme != it->second.end(); ++addme) {
origp->addNextHere(*addme); origp->addNextHere(*addme);
RemovePlaceholdersVisitor removePlaceholders(*addme); RemovePlaceholdersVisitor removePlaceholders(*addme);