about summary refs log tree commit diff
path: root/compiler/rustc_data_structures/src/graph/dominators
AgeCommit message (Collapse)AuthorLines
2025-02-08Rustfmtbjorn3-39/+26
2024-10-24Replace an FTP link in comments with an equivalent HTTPS linkZalathar-1/+1
2024-10-22Move `cmp_in_dominator_order` out of graph dominator computationZalathar-22/+1
Dominator-order information is only needed for coverage graphs, and is easy enough to collect by just traversing the graph again. This avoids wasted work when computing graph dominators for any other purpose.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-26/+39
2024-07-29Reformat `use` declarations.Nicholas Nethercote-4/+4
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-05-30Apply x clippy --fix and x fmtr0cky-1/+1
2024-04-03rustc_index: Add a `ZERO` constant to index typesVadim Petrochenkov-4/+4
It is commonly used.
2023-12-31Inline dominator check.Camille GILLOT-0/+1
2023-11-22Replace `no_ord_impl` with `orderable`.Nicholas Nethercote-0/+1
Similar to the previous commit, this replaces `newtype_index`'s opt-out `no_ord_impl` attribute with the opt-in `orderable` attribute.
2023-10-10Remove unused dominator iteratorTomasz Miąsko-26/+1
2023-10-05Optimize dominators for small path graphsTomasz Miąsko-10/+65
Generalizes the small dominators approach from #107449.
2023-10-05Remove redundant Dominators::start_node fieldTomasz Miąsko-3/+2
2023-10-05Test immediate dominators using public APITomasz Miąsko-24/+21
2023-09-18coverage: Simplify sorting of coverage spans extracted from MIRZalathar-3/+3
Switching to `Ordering::then_with` makes control-flow less complicated, and there is no need to use `partial_cmp` here.
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-3/+1
2023-05-24Auto merge of #111673 - cjgillot:dominator-preprocess, r=cjgillot,tmiaskobors-10/+85
Preprocess and cache dominator tree Preprocessing dominators has a very strong effect for https://github.com/rust-lang/rust/pull/111344. That pass checks that assignments dominate their uses repeatedly. Using the unprocessed dominator tree caused a quadratic runtime (number of bbs x depth of the dominator tree). This PR also caches the dominator tree and the pre-processed dominators in the MIR cfg cache. Rebase of https://github.com/rust-lang/rust/pull/107157 cc `@tmiasko`
2023-05-18Revert spurious changes.Camille GILLOT-9/+9
2023-05-17Merge DominatorTree and Dominators.Camille GILLOT-36/+30
2023-05-17Typo.Camille GILLOT-1/+1
2023-05-17Remove outdated comment.Camille GILLOT-2/+0
2023-05-17Preprocess dominator tree to answer queries in O(1)Tomasz Miąsko-22/+105
2023-05-15Process current bucket instead of parent's bucket when starting loop for ↵Camille GILLOT-8/+35
dominators.
2023-05-14Start node has no immediate dominatorTomasz Miąsko-14/+22
Change the immediate_dominator return type to Option, and use None to indicate that node has no immediate dominator. Also fix the issue where the start node would be returned as its own immediate dominator.
2023-04-24Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle-1/+2
2023-04-02Use `&IndexSlice` instead of `&IndexVec` where possibleScott McMurray-7/+7
All the same reasons as for `[T]`: more general, less pointer chasing, and `&mut IndexSlice` emphasizes that it doesn't change *length*.
2023-01-24Improve efficiency of has_back_edge(...)Bryan Garza-0/+7
2023-01-23Add comment on cause of panic in dominators algorithmBryan Garza-1/+41
2023-01-23Rollup merge of #107153 - tmiasko:dominates, r=oli-obkYuki Okushi-1/+1
Consistently use dominates instead of is_dominated_by There is a number of APIs that answer dominance queries. Previously they were named either "dominates" or "is_dominated_by". Consistently use the "dominates" form. No functional changes.
2023-01-21Consistently use dominates instead of is_dominated_byTomasz Miąsko-1/+1
There is a number of APIs that answer dominance queries. Previously they were named either "dominates" or "is_dominated_by". Consistently use the "dominates" form. No functional changes.
2023-01-21Auto merge of #106976 - tmiasko:borrowck-lazy-dominators, r=cjgillotbors-4/+0
Lazy dominator tree construction in borrowck Motivated by the observation that sometimes constructed dominator tree was never queried.
2023-01-18Fix Dominators::rank_partial_cmp to match documentationTomasz Miąsko-1/+1
The only use site is also updated accordingly and there is no change in end-to-end behaviour.
2023-01-17Lazy dominator tree construction in borrowckTomasz Miąsko-4/+0
Motivated by the observation that sometimes constructed dominator tree was never queried.
2023-01-16Document wf constraints on control flow in cleanup blocksJakob Degen-1/+4
Also fixes a bug in dominator computation
2023-01-05Fix `uninlined_format_args` for some compiler cratesnils-2/+2
Convert all the crates that have had their diagnostic migration completed (except save_analysis because that will be deleted soon and apfloat because of the licensing problem).
2022-12-18A few small cleanups for `newtype_index`Nilstrieb-1/+1
Remove the `..` from the body, only a few invocations used it and it's inconsistent with rust syntax. Use `;` instead of `,` between consts. As the Rust syntax gods inteded.
2022-02-23Avoid exhausting stack space in dominator compressionMark Rousskov-3/+13
2021-12-06Annotate comments onto the LT algorithmMark Rousskov-2/+102
2021-12-06Avoid using Option where values are always SomeMark Rousskov-9/+13
2021-12-06Create newtype around the pre order indexMark Rousskov-32/+41
2021-12-06Use variables rather than lengths directlyMark Rousskov-10/+13
2021-12-06Optimize: reuse the real-to-preorder mapping as the visited setMark Rousskov-4/+2
2021-12-06Remove separate RPO traversalMark Rousskov-17/+7
This integrates the preorder and postorder traversals into one.
2021-12-06Use preorder indices for data structuresMark Rousskov-53/+38
This largely avoids remapping from and to the 'real' indices, with the exception of predecessor lookup and the final merge back, and is conceptually better.
2021-12-06Avoid inserting into buckets if not necessaryMark Rousskov-1/+7
2021-12-06Optimization: process buckets only onceMark Rousskov-7/+8
2021-12-06Optimization: Merge parent and ancestor arraysMark Rousskov-10/+21
As the paper indicates, the unprocessed vertices in the DFS tree and processed vertices are disjoint, and we can use them in the same space, tracking only the index of the split.
2021-12-06Implement the simple Lengauer-Tarjan algorithmMark Rousskov-39/+116
This replaces the previous implementation with the simple variant of Lengauer-Tarjan, which performs better in the general case. Performance on the keccak benchmark is about equivalent between the two, but we don't see regressions (and indeed see improvements) on other benchmarks, even on a partially optimized implementation. The implementation here follows that of the pseudocode in "Linear-Time Algorithms for Dominators and Related Problems" thesis by Loukas Georgiadis. The next few commits will optimize the implementation as suggested in the thesis. Several related works are cited in the comments within the implementation, as well. Implement the simple Lengauer-Tarjan algorithm This replaces the previous implementation (from #34169), which has not been optimized since, with the simple variant of Lengauer-Tarjan which performs better in the general case. A previous attempt -- not kept in commit history -- attempted a replacement with a bitset-based implementation, but this led to regressions on perf.rust-lang.org benchmarks and equivalent wins for the keccak benchmark, so was rejected. The implementation here follows that of the pseudocode in "Linear-Time Algorithms for Dominators and Related Problems" thesis by Loukas Georgiadis. The next few commits will optimize the implementation as suggested in the thesis. Several related works are cited in the comments within the implementation, as well. On the keccak benchmark, we were previously spending 15% of our cycles computing the NCA / intersect function; this function is quite expensive, especially on modern CPUs, as it chases pointers on every iteration in a tight loop. With this commit, we spend ~0.05% of our time in dominator computation.
2021-02-10Only initialize what is usedDániel Buga-0/+4
2021-01-24Clean up dominators_given_rpoDániel Buga-11/+5
2020-10-05Updates to experimental coverage counter injectionRich Kadel-0/+9
This is a combination of 18 commits. Commit #2: Additional examples and some small improvements. Commit #3: fixed mir-opt non-mir extensions and spanview title elements Corrected a fairly recent assumption in runtest.rs that all MIR dump files end in .mir. (It was appending .mir to the graphviz .dot and spanview .html file names when generating blessed output files. That also left outdated files in the baseline alongside the files with the incorrect names, which I've now removed.) Updated spanview HTML title elements to match their content, replacing a hardcoded and incorrect name that was left in accidentally when originally submitted. Commit #4: added more test examples also improved Makefiles with support for non-zero exit status and to force validation of tests unless a specific test overrides it with a specific comment. Commit #5: Fixed rare issues after testing on real-world crate Commit #6: Addressed PR feedback, and removed temporary -Zexperimental-coverage -Zinstrument-coverage once again supports the latest capabilities of LLVM instrprof coverage instrumentation. Also fixed a bug in spanview. Commit #7: Fix closure handling, add tests for closures and inner items And cleaned up other tests for consistency, and to make it more clear where spans start/end by breaking up lines. Commit #8: renamed "typical" test results "expected" Now that the `llvm-cov show` tests are improved to normally expect matching actuals, and to allow individual tests to override that expectation. Commit #9: test coverage of inline generic struct function Commit #10: Addressed review feedback * Removed unnecessary Unreachable filter. * Replaced a match wildcard with remining variants. * Added more comments to help clarify the role of successors() in the CFG traversal Commit #11: refactoring based on feedback * refactored `fn coverage_spans()`. * changed the way I expand an empty coverage span to improve performance * fixed a typo that I had accidently left in, in visit.rs Commit #12: Optimized use of SourceMap and SourceFile Commit #13: Fixed a regression, and synched with upstream Some generated test file names changed due to some new change upstream. Commit #14: Stripping out crate disambiguators from demangled names These can vary depending on the test platform. Commit #15: Ignore llvm-cov show diff on test with generics, expand IO error message Tests with generics produce llvm-cov show results with demangled names that can include an unstable "crate disambiguator" (hex value). The value changes when run in the Rust CI Windows environment. I added a sed filter to strip them out (in a prior commit), but sed also appears to fail in the same environment. Until I can figure out a workaround, I'm just going to ignore this specific test result. I added a FIXME to follow up later, but it's not that critical. I also saw an error with Windows GNU, but the IO error did not specify a path for the directory or file that triggered the error. I updated the error messages to provide more info for next, time but also noticed some other tests with similar steps did not fail. Looks spurious. Commit #16: Modify rust-demangler to strip disambiguators by default Commit #17: Remove std::process::exit from coverage tests Due to Issue #77553, programs that call std::process::exit() do not generate coverage results on Windows MSVC. Commit #18: fix: test file paths exceeding Windows max path len