Skip to content

Commit

Permalink
[LowerClass] Run path tracking sequentially (#7221)
Browse files Browse the repository at this point in the history
This fixes a race condition was introduced by [0] for now by removing parallesim
[0] d00a1d2
  • Loading branch information
uenoku authored Jun 21, 2024
1 parent e89910a commit f4920aa
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions lib/Dialect/FIRRTL/Transforms/LowerClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,27 +302,14 @@ PathTracker::run(CircuitOp circuit, InstanceGraph &instanceGraph,
const DenseMap<DistinctAttr, FModuleOp> &owningModules) {
SmallVector<PathTracker> trackers;

// First allocate module namespaces. Don't capture a namespace reference at
// this point since they could be invalidated when DenseMap grows.
for (auto *node : instanceGraph)
if (auto module = node->getModule<FModuleLike>())
(void)namespaces.get(module);

// Prepare workers.
for (auto *node : instanceGraph)
if (auto module = node->getModule<FModuleLike>())
trackers.emplace_back(module, namespaces, instanceGraph, symbolTable,
owningModules);

if (failed(failableParallelForEach(
circuit.getContext(), trackers,
[](PathTracker &tracker) { return tracker.runOnModule(); })))
return failure();

// Update the pathInfoTable sequentially.
for (const auto &tracker : trackers)
if (failed(tracker.updatePathInfoTable(pathInfoTable, cache)))
return failure();
if (auto module = node->getModule<FModuleLike>()) {
PathTracker tracker(module, namespaces, instanceGraph, symbolTable,
owningModules);
if (failed(tracker.runOnModule()))
return failure();
tracker.updatePathInfoTable(pathInfoTable, cache);
}

return success();
}
Expand Down

0 comments on commit f4920aa

Please sign in to comment.