[llvm] Clean backport of upstream PR183272 - #23284
Draft
hahnjo wants to merge 2 commits into
Draft
Conversation
This reapplies 85354c6d8bc, which was reverted in d7347c0b81a due to bot failures. In this commit further changes are made to address the bot failure, and general readability. WaitingOnGraph::Coalescer::remove is renamed WaitingOnGraph::Coalescer::erase, since its behavior is now similar to common container erase operations. WaitingOnGraph::Coalescer::clear is provided to enable a fast reset of Coalescer state. SuperNodeBuilder::takeSuperNodes is updated to clear the Coalescer state before returning the SuperNodes, ensuring that future calls to SuperNodeBuilder::add do not trip the assert that caused the builder failures.
This commit replaces the core dependence propagation algorithm in WaitingOnGraph to avoid worst-case behavior in the common case where dependence graphs are sparse. This algorithm showed up as the underlying cause of the bug in llvm/llvm-project#179611. For each call to MaterializationResponsibility::notifyEmitted, WaitingOnGraph would build the transitive closure of all SuperNodes whose "waiting on" relationships were affected by the newly emitted symbols, then propagate any remaining unemitted dependencies through this transitive closure graph. This approach is simple, but pushes the algorithm towards n^2 complexity even for sparse dependence graphs. The new propagation algorithm: 1. Inverts the edge direction in the SymbolDependenceMap data structure: SymbolDepMap[SN] now contains the set of SuperNodes that depend on SN, rather than the set that SN depends upon. 2. Pushes dependencies through the SymbolDepMap iteratively until it reaches a fixed point. This updated algorithm converges much more quickly than the original for the testcase reported in the issue, and for other cases tested so far. No testcase yet, as this only affects performance. I've filed a follow-up issue, llvm/llvm-project#183251, to track construction of performance testing infrastructure for WaitingOnGraph. Should fix llvm/llvm-project#179611
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport llvm/llvm-project@55ce4b7 as a dependency of llvm/llvm-project@db5ffb0 (llvm/llvm-project#183272)
(Clean) alternative to #23249