about summary refs log tree commit diff
path: root/compiler/rustc_data_structures/src
AgeCommit message (Collapse)AuthorLines
2020-12-18Switch compiler/ to intra-doc linksJoshua Nelson-4/+1
rustc_lint and rustc_lint_defs weren't switched because they're included in the compiler book and so can't use intra-doc links.
2020-11-23Rename `optin_builtin_traits` to `auto_traits`Camelid-1/+2
They were originally called "opt-in, built-in traits" (OIBITs), but people realized that the name was too confusing and a mouthful, and so they were renamed to just "auto traits". The feature flag's name wasn't updated, though, so that's what this PR does. There are some other spots in the compiler that still refer to OIBITs, but I don't think changing those now is worth it since they are internal and not particularly relevant to this PR. Also see <https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/opt-in.2C.20built-in.20traits.20(auto.20traits).20feature.20name>.
2020-11-21Auto merge of #78588 - HeroicKatora:sccc, r=nikomatsakisbors-95/+364
Reworks Sccc computation to iteration instead of recursion Linear graphs, producing as many scc's as nodes, would recurse once for every node when entered from the start of the list. This adds a test that exhausted the stack at least on my machine with error: ``` thread 'graph::scc::tests::test_deep_linear' has overflowed its stack fatal runtime error: stack overflow ``` This may or may not be connected to #78567. I was only reminded that I started this rework some time ago. It might be plausible as borrow checking a long function with many borrow regions around each other—((((((…))))))— may produce the linear list setup to trigger this stack overflow ? I don't know enough about borrow check to say for sure. This is best read in two separate commits. The first addresses only `find_state` internally. This is classical union phase from union-find. There's also a common solution of using the parent pointers in the (virtual) linked list to track the backreferences while traversing upwards and then following them backwards in a second path compression phase. The second is more involved as it rewrites the mutually recursive `walk_node` and `walk_unvisited_node`. Firstly, the caller is required to handle the unvisited case of `walk_node` so a new `start_walk_from` method is added to handle that by walking the unvisited node if necessary. Then `walk_unvisited_node`, where we would previously recurse into in the missing case, is rewritten to construct a manual stack of its frames. The state fields consist of the previous stack slots.
2020-11-20Set unaligned_references lint to deny in rustc_data_structuresTyson Nottingham-0/+1
To detect misuse of private packed field in `PackedFingerprint`.
2020-11-18Make PackedFingerprint's Fingerprint privateTyson Nottingham-1/+18
2020-11-18Use PackedFingerprint in DepNode to reduce memory consumptionTyson Nottingham-0/+42
2020-11-17Rollup merge of #78702 - wesleywiser:self_profile_cgu_sizes, r=Mark-SimulacrumMara Bos-0/+22
[self-profiling] Include the estimated size of each cgu in the profile This is helpful when looking for CGUs where the size estimate isn't a good indicator of compilation time. I verified that moving the profiling timer call doesn't affect the results. Results: <img width="297" alt="Screen Shot 2020-11-03 at 7 25 04 AM" src="https://user-images.githubusercontent.com/831192/97985503-5901d100-1da6-11eb-9f10-f3e399702952.png"> `measureme` doesn't have support for custom arg names yet so `arg0` is the CGU name and `arg1` is the estimated size.
2020-11-16wordslcnr-1/+1
2020-11-16compiler: fold by valueBastian Kauschke-0/+2
2020-11-16add IdFunctor to rustc_data_structuresBastian Kauschke-0/+82
2020-11-15Rollup merge of #79058 - dtolnay:likelymacro, r=Mark-SimulacrumJonas Schievink-6/+6
Move likely/unlikely argument outside of invisible unsafe block The previous `likely!`/`unlikely!` macros were unsound because it permits the caller's expr to contain arbitrary unsafe code. ```rust pub fn huh() -> bool { likely!(std::ptr::read(&() as *const () as *const bool)) } ``` **Before:** compiles cleanly. **After:** ```console error[E0133]: call to unsafe function is unsafe and requires unsafe function or block | 70 | likely!(std::ptr::read(&() as *const () as *const bool)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function | = note: consult the function's documentation for information on how to avoid undefined behavior ```
2020-11-14Move likely/unlikely argument outside of invisible unsafe blockDavid Tolnay-6/+6
The previous `likely!`/`unlikely!` macros were unsound because it permits the caller's expr to contain arbitrary unsafe code. pub fn huh() -> bool { likely!(std::ptr::read(&() as *const () as *const bool)) } Before: compiles cleanly. After: error[E0133]: call to unsafe function is unsafe and requires unsafe function or block | 70 | likely!(std::ptr::read(&() as *const () as *const bool)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function | = note: consult the function's documentation for information on how to avoid undefined behavior
2020-11-14Move Steal to rustc_data_structures.Camille GILLOT-0/+52
2020-11-08Remove recursion from sccc walkingAndreas Molzer-73/+182
This allows constructing the sccc for large that visit many nodes before finding a single cycle of sccc, for example lists. When used to find dependencies in borrow checking the list case is what occurs in very long functions.
2020-11-05Add test for sccc of a long listAndreas Molzer-0/+26
2020-11-05Convert the recursive find_state to a loopAndreas Molzer-22/+110
The basic conversion is a straightforward conversion of the linear recursion to a loop forwards and backwards propagation of the result. But this uses an optimization to avoid the need for extra space that would otherwise be necessary to store the stack of unfinished states as the function is not tail recursive. Observe that only non-root-nodes in cycles have a recursive call and that every such call overwrites their own node state. Thus we reuse the node state itself as temporary storage for the stack of unfinished states by inverting the links to a chain back to the previous state update. When we hit the root or end of the full explored chain we propagate the node state update backwards by following the chain until a node with a link to itself.
2020-11-03[self-profiling] Include the estimated size of each cgu in the profileWesley Wiser-0/+22
This is helpful when looking for CGUs where the size estimate isn't a good indicator of compilation time. I verified that moving the profiling timer call doesn't affect the results.
2020-10-31Move post order walk to iterative approachAndreas Molzer-5/+20
The previous recursive approach might overflow the stack when walking a particularly deep, list-like, graph. In particular, dominator calculation for borrow checking does such a traversal and very long functions might lead to a region dependency graph with in this problematic structure.
2020-10-31Add a benchmark test for sccc findingAndreas Molzer-0/+46
While a bit primitive, it should get us at least a better number than nothing.
2020-10-30Fix even more clippy warningsJoshua Nelson-7/+4
2020-10-30Rollup merge of #78524 - tmiasko:source-files-borrow, r=Aaron1011Yuki Okushi-1/+1
Avoid BorrowMutError with RUSTC_LOG=debug ```console $ touch empty.rs $ env RUSTC_LOG=debug rustc +stage1 --crate-type=lib empty.rs ``` Fails with a `BorrowMutError` because source map files are already borrowed while `features_query` attempts to format a log message containing a span. Release the borrow before the query to avoid the issue.
2020-10-29Fix typosDániel Buga-3/+3
2020-10-29Use RwLock instead of Lock for SourceMap::filesTomasz Miąsko-1/+1
2020-10-27Fix typo in vec_graphDániel Buga-1/+1
2020-10-25Auto merge of #77476 - tgnottingham:buffered_siphasher128, r=nnethercotebors-196/+389
perf: buffer SipHasher128 This is an attempt to improve Siphasher128 performance by buffering input. Although it reduces instruction count, I'm not confident the effect on wall times, or lack-thereof, is worth the change. --- Additional notes not reflected in source comments: * Implementation choices were guided by a combination of results from rustc-perf and micro-benchmarks, mostly the former. * ~~I tried a couple of different struct layouts that might be more cache friendly with no obvious effect.~~ Update: a particular struct layout was chosen, but it's not critical to performance. See comments in source and discussion below. * I suspect that buffering would be important to a SIMD-accelerated algorithm, but from what I've read and my own tests, SipHash does not seem very amenable to SIMD acceleration, at least by SSE.
2020-10-24Upgrade to measureme 9.0.0Wesley Wiser-18/+4
2020-10-24Rollup merge of #77830 - cjgillot:remacro, r=oli-obkJonas Schievink-11/+0
Simplify query proc-macros The query code generation is split between proc-macros and regular macros in `rustc_middle::ty::query`. This PR removes unused capabilities of the proc-macros, and tend to use regular macros for the logic.
2020-10-22Don't re-export std::ops::ControlFlow in the compiler.Leonora Tindall-3/+1
2020-10-22change the order of type arguments on ControlFlowLeonora Tindall-2/+1
This allows ControlFlow<BreakType> which is much more ergonomic for common iterator combinator use cases.
2020-10-22Remove unused ProfileCategory.Camille GILLOT-11/+0
2020-10-19Auto merge of #77908 - bugadani:obl-forest, r=nnethercotebors-350/+325
Try to make ObligationForest more efficient This PR tries to decrease the number of allocations in ObligationForest, as well as moves some cold path code to an uninlined function.
2020-10-18Stabilize or_insert_with_keyChai T. Rex-1/+1
2020-10-15Turn Outcome into an opaque type to remove some runtime checksDániel Buga-341/+315
2020-10-15Reuse memory for process_cyclesDániel Buga-8/+8
2020-10-15Make sure cold code is as small as possibleDániel Buga-1/+2
2020-10-14Remove unused code from remaining compiler cratesest31-6/+0
2020-10-13Replace absolute paths with relative onesest31-7/+7
Modern compilers allow reaching external crates like std or core via relative paths in modules outside of lib.rs and main.rs.
2020-10-11SipHasher128: improve constant names and add more commentsTyson Nottingham-38/+68
2020-10-05Auto merge of #77080 - richkadel:llvm-coverage-counters-2, r=tmandrybors-0/+9
Working branch-level code coverage Add a generalized implementation for computing branch-level coverage spans. This iteration resolves some of the challenges I had identified a few weeks ago. I've tried to implement a solution that is general enough to work for a lot of different graphs/patterns. It's encouraging to see the results on fairly large and complex crates seem to meet my expectations. This may be a "functionally complete" implementation. Except for bug fixes or edge cases I haven't run into yet, the next and essentially final step, I think, is to replace some Counters with CounterExpressions (where their counter values can be computed by adding or subtracting other counters/expressions). Examples of branch-level coverage support enabled in this PR: * https://github.com/richkadel/rust/blob/llvm-coverage-counters-2/src/test/run-make-fulldeps/instrument-coverage-cov-reports-base/expected_show_coverage.coverage_of_drop_trait.txt * https://github.com/richkadel/rust/blob/llvm-coverage-counters-2/src/test/run-make-fulldeps/instrument-coverage-cov-reports-base/expected_show_coverage.coverage_of_if.txt * https://github.com/richkadel/rust/blob/llvm-coverage-counters-2/src/test/run-make-fulldeps/instrument-coverage-cov-reports-base/expected_show_coverage.coverage_of_if_else.txt * https://github.com/richkadel/rust/blob/llvm-coverage-counters-2/src/test/run-make-fulldeps/instrument-coverage-cov-reports-base/expected_show_coverage.coverage_of_simple_loop.txt * https://github.com/richkadel/rust/blob/llvm-coverage-counters-2/src/test/run-make-fulldeps/instrument-coverage-cov-reports-base/expected_show_coverage.coverage_of_simple_match.txt * ... _and others in the same directory_ Examples of coverage analysis results (MIR spanview files) used to inject counters in the right `BasicBlocks`: * https://htmlpreview.github.io/?https://github.com/richkadel/rust/blob/llvm-coverage-counters-2/src/test/run-make-fulldeps/instrument-coverage-mir-cov-html-base/expected_mir_dump.coverage_of_drop_trait/coverage_of_drop_trait.main.-------.InstrumentCoverage.0.html * https://htmlpreview.github.io/?https://github.com/richkadel/rust/blob/llvm-coverage-counters-2/src/test/run-make-fulldeps/instrument-coverage-mir-cov-html-base/expected_mir_dump.coverage_of_if/coverage_of_if.main.-------.InstrumentCoverage.0.html * https://htmlpreview.github.io/?https://github.com/richkadel/rust/blob/llvm-coverage-counters-2/src/test/run-make-fulldeps/instrument-coverage-mir-cov-html-base/expected_mir_dump.coverage_of_if_else/coverage_of_if_else.main.-------.InstrumentCoverage.0.html * https://htmlpreview.github.io/?https://github.com/richkadel/rust/blob/llvm-coverage-counters-2/src/test/run-make-fulldeps/instrument-coverage-mir-cov-html-base/expected_mir_dump.coverage_of_simple_loop/coverage_of_simple_loop.main.-------.InstrumentCoverage.0.html * https://htmlpreview.github.io/?https://github.com/richkadel/rust/blob/llvm-coverage-counters-2/src/test/run-make-fulldeps/instrument-coverage-mir-cov-html-base/expected_mir_dump.coverage_of_simple_match/coverage_of_simple_match.main.-------.InstrumentCoverage.0.html * ... _and others in the same directory_ Here is some sample coverage output after compiling a few real-world crates with the new branch-level coverage features: <img width="801" alt="Screen Shot 2020-09-25 at 1 03 11 PM" src="https://user-images.githubusercontent.com/3827298/94316848-fd882c00-ff39-11ea-9cff-0402d3abd1e7.png"> <img width="721" alt="Screen Shot 2020-09-25 at 1 00 36 PM" src="https://user-images.githubusercontent.com/3827298/94316886-11cc2900-ff3a-11ea-9d03-80b26c8a5173.png"> <img width="889" alt="Screen Shot 2020-09-25 at 12 54 57 PM" src="https://user-images.githubusercontent.com/3827298/94316900-18f33700-ff3a-11ea-8a80-58f67d84b8de.png"> r? `@tmandry` FYI: `@wesleywiser`
2020-10-05Auto merge of #77171 - VFLashM:better_sso_structures, r=oli-obkbors-104/+879
Better sso structures This change greatly expands interface of MiniSet/MiniMap and renames them because they are no longer "Mini".
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
2020-10-05SipHasher128: use specific struct layoutTyson Nottingham-0/+6
2020-10-05SipHasher128: use more named constants, update commentsTyson Nottingham-50/+54
2020-10-03perf: buffer SipHasher128Tyson Nottingham-196/+349
2020-10-02SsoHashSet/Map - genericiy over Q removedValerii Lashmanov-89/+72
Due to performance regression, see SsoHashMap comment.
2020-09-30Stable hashing: add comments and tests concerning platform-independenceTyson Nottingham-18/+142
SipHasher128 implements short_write in an endian-independent way, yet its write_xxx Hasher trait methods undo this endian-independence by byte swapping the integer inputs on big-endian hardware. StableHasher then adds endian-independence back by also byte-swapping on big-endian hardware prior to invoking SipHasher128. This double swap may have the appearance of being a no-op, but is in fact by design. In particular, we really do want SipHasher128 to be platform-dependent, in order to be consistent with the libstd SipHasher. Try to clarify this intent. Also, add and update a couple of unit tests.
2020-09-27SsoHashMap minor refactoring, SSO_ARRAY_SIZE introducedValerii Lashmanov-12/+29
2020-09-26SsoHashSet reimplemented as a wrapper on top of SsoHashMapValerii Lashmanov-228/+158
SsoHashSet::replace had to be removed because it requires missing API from SsoHashMap. It's not a widely used function, so I think it's ok to omit it for now. EitherIter moved into its own file. Also sprinkled code with #[inline] attributes where appropriate.
2020-09-26SsoHashSet/SsoHashMap API greatly expandedValerii Lashmanov-23/+864
Now both provide almost complete API of their non-SSO counterparts.
2020-09-26MiniSet/MiniMap moved and renamed into SsoHashSet/SsoHashMapValerii Lashmanov-18/+22
It is a more descriptive name and with upcoming changes there will be nothing "mini" about them.