about summary refs log tree commit diff
path: root/compiler/rustc_span
AgeCommit message (Collapse)AuthorLines
2022-06-02Basic compiler infraCaio-0/+1
2022-06-02Address review comments.Nicholas Nethercote-40/+62
2022-06-01Lazify `SourceFile::lines`.Nicholas Nethercote-97/+181
`SourceFile::lines` is a big part of metadata. It's stored in a compressed form (a difference list) to save disk space. Decoding it is a big fraction of compile time for very small crates/programs. This commit introduces a new type `SourceFileLines` which has a `Lines` form and a `Diffs` form. The latter is used when the metadata is first read, and it is only decoded into the `Lines` form when line data is actually needed. This avoids the decoding cost for many files, especially in `std`. It's a performance win of up to 15% for tiny crates/programs where metadata decoding is a high part of compilation costs. A `Lock` is needed because the methods that access lines data (which can trigger decoding) take `&self` rather than `&mut self`. To allow for this, `SourceFile::lines` now takes a `FnMut` that operates on the lines slice rather than returning the lines slice.
2022-06-01Add #[rustc_box]est31-0/+1
This commit adds an alternative content boxing syntax, and uses it inside alloc. The usage inside the very performance relevant code in liballoc is the only remaining relevant usage of box syntax in the compiler (outside of tests, which are comparatively easy to port). box syntax was originally designed to be used by all Rust developers. This introduces a replacement syntax more tailored to only being used inside the Rust compiler, and with it, lays the groundwork for eventually removing box syntax.
2022-05-30Auto merge of #96964 - oli-obk:const_trait_mvp, r=compiler-errorsbors-0/+1
Replace `#[default_method_body_is_const]` with `#[const_trait]` pulled out of #96077 related issues: #67792 and #92158 cc `@fee1-dead` This is groundwork to only allowing `impl const Trait` for traits that are marked with `#[const_trait]`. This is necessary to prevent adding a new default method from becoming a breaking change (as it could be a non-const fn).
2022-05-30Remove `#[default..]` and add `#[const_trait]`Deadbeef-0/+1
2022-05-30Add support for emitting functions with `coldcc` in LLVMScott McMurray-0/+1
The eventual goal is to try using this for things like the internal panicking stuff, to see whether it helps.
2022-05-29Auto merge of #97287 - compiler-errors:type-interner, r=jackh726,oli-obkbors-0/+1
Move things to `rustc_type_ir` Finishes some work proposed in https://github.com/rust-lang/compiler-team/issues/341. r? `@ghost`
2022-05-29Rollup merge of #97028 - ridwanabdillahi:pretty-printer, r=michaelwoeristerGuillaume Gomez-0/+2
Add support for embedding pretty printers via `#[debugger_visualizer]` attribute Initial support for [RFC 3191](https://github.com/rust-lang/rfcs/pull/3191) in PR https://github.com/rust-lang/rust/pull/91779 was scoped to supporting embedding NatVis files using a new attribute. This PR implements the pretty printer support as stated in the RFC mentioned above. This change includes embedding pretty printers in the `.debug_gdb_scripts` just as the pretty printers for rustc are embedded today. Also added additional tests for embedded pretty printers. Additionally cleaned up error checking so all error checking is done up front regardless of the current target. RFC: https://github.com/rust-lang/rfcs/pull/3191
2022-05-28Fix TyKind lint, make consts no longer fn, etcMichael Goulet-0/+1
2022-05-26Auto merge of #97386 - nnethercote:optimize-pos-adjustments, r=bjorn3bors-8/+17
Optimize position adjustments A small improvement. r? `@bjorn3`
2022-05-26Avoid adjusting file positions twice.Nicholas Nethercote-7/+14
`imported_source_files` adjusts lots of file positions, and then calls `new_imported_source_file`, which then adjust them all again. This commit combines the two adjustments into one, for a small perf win.
2022-05-26Augment a comment.Nicholas Nethercote-1/+3
2022-05-24Add support for embedding pretty printers via the `#[debugger_visualizer]` ↵ridwanabdillahi-0/+2
attribute. Add tests for embedding pretty printers and update documentation. Ensure all error checking for `#[debugger_visualizer]` is done up front and not when the `debugger_visualizer` query is run. Clean up potential ODR violations when embedding pretty printers into the `__rustc_debug_gdb_scripts_section__` section. Respond to PR comments and update documentation.
2022-05-24RFC3239: Implement compact `cfg(target(..))`Loïc BRANSTETT-0/+2
2022-05-20Remove `crate` visibility usage in compilerJacob Pratt-5/+4
2022-05-18Properly apply path prefix remapping paths emitted into debuginfo.Michael Woerister-3/+5
2022-05-18Add tests for FilePathMapping::to_embeddable_absolute_path().Michael Woerister-41/+128
2022-05-18Move logic for making potentially remapped paths absolute into helper method.Michael Woerister-0/+79
2022-05-18Add debug tracing to FilePathMapping::map_prefixMichael Woerister-19/+34
2022-05-16Add tmm_reg clobbersConnor Horman-0/+1
2022-05-11Add `unsigned_offset_from` on pointersScott McMurray-0/+1
Like we have `add`/`sub` which are the `usize` version of `offset`, this adds the `usize` equivalent of `offset_from`. Like how `.add(d)` replaced a whole bunch of `.offset(d as isize)`, you can see from the changes here that it's fairly common that code actually knows the order between the pointers and *wants* a `usize`, not an `isize`. As a bonus, this can do `sub nuw`+`udiv exact`, rather than `sub`+`sdiv exact`, which can be optimized slightly better because it doesn't have to worry about negatives. That's why the slice iterators weren't using `offset_from`, though I haven't updated that code in this PR because slices are so perf-critical that I'll do it as its own change. This is an intrinsic, like `offset_from`, so that it can eventually be allowed in CTFE. It also allows checking the extra safety condition -- see the test confirming that CTFE catches it if you pass the pointers in the wrong order.
2022-05-07Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errorsbors-7/+10
Begin fixing all the broken doctests in `compiler/` Begins to fix #95994. All of them pass now but 24 of them I've marked with `ignore HELP (<explanation>)` (asking for help) as I'm unsure how to get them to work / if we should leave them as they are. There are also a few that I marked `ignore` that could maybe be made to work but seem less important. Each `ignore` has a rough "reason" for ignoring after it parentheses, with - `(pseudo-rust)` meaning "mostly rust-like but contains foreign syntax" - `(illustrative)` a somewhat catchall for either a fragment of rust that doesn't stand on its own (like a lone type), or abbreviated rust with ellipses and undeclared types that would get too cluttered if made compile-worthy. - `(not-rust)` stuff that isn't rust but benefits from the syntax highlighting, like MIR. - `(internal)` uses `rustc_*` code which would be difficult to make work with the testing setup. Those reason notes are a bit inconsistently applied and messy though. If that's important I can go through them again and try a more principled approach. When I run `rg '```ignore \(' .` on the repo, there look to be lots of different conventions other people have used for this sort of thing. I could try unifying them all if that would be helpful. I'm not sure if there was a better existing way to do this but I wrote my own script to help me run all the doctests and wade through the output. If that would be useful to anyone else, I put it here: https://github.com/Elliot-Roberts/rust_doctest_fixing_tool
2022-05-07Remove closures on `expect_local` to apply `#[track_caller]`Yuki Okushi-1/+6
2022-05-05Rollup merge of #96747 - JohnTitor:expect-local-track-caller, r=compiler-errorsMichael Goulet-0/+1
Add `track_caller` to `DefId::expect_local()` Suggested in https://github.com/rust-lang/rust/issues/96738#issuecomment-1118961888. `DefId::expect_local()` often causes ICEs (panics) and should be a good candidate to add `track_caller`.
2022-05-05Auto merge of #96520 - lcnr:general-incoherent-impls, r=petrochenkovbors-0/+1
generalize "incoherent impls" impl for user defined types To allow the move of `trait Error` into core. continues the work from #94963, finishes https://github.com/rust-lang/compiler-team/issues/487 r? `@petrochenkov` cc `@yaahc`
2022-05-06Add `track_caller` to `DefId::expect_local()`Yuki Okushi-0/+1
2022-05-05Auto merge of #91779 - ridwanabdillahi:natvis, r=michaelwoeristerbors-0/+25
Add a new Rust attribute to support embedding debugger visualizers Implemented [this RFC](https://github.com/rust-lang/rfcs/pull/3191) to add support for embedding debugger visualizers into a PDB. Added a new attribute `#[debugger_visualizer]` and updated the `CrateMetadata` to store debugger visualizers for crate dependencies. RFC: https://github.com/rust-lang/rfcs/pull/3191
2022-05-05generalize "incoherent impls" impl for custom typeslcnr-0/+1
2022-05-04Stabilize `bool::then_some`Josh Triplett-1/+0
2022-05-03Add support for a new attribute `#[debugger_visualizer]` to support ↵ridwanabdillahi-0/+25
embedding debugger visualizers into a generated PDB. Cleanup `DebuggerVisualizerFile` type and other minor cleanup of queries. Merge the queries for debugger visualizers into a single query. Revert move of `resolve_path` to `rustc_builtin_macros`. Update dependencies in Cargo.toml for `rustc_passes`. Respond to PR comments. Load visualizer files into opaque bytes `Vec<u8>`. Debugger visualizers for dynamically linked crates should not be embedded in the current crate. Update the unstable book with the new feature. Add the tracking issue for the debugger_visualizer feature. Respond to PR comments and minor cleanups.
2022-05-02fix most compiler/ doctestsElliot Roberts-7/+10
2022-04-30Add `do yeet` expressions to allow experimentation in nightlyScott McMurray-0/+6
Using an obviously-placeholder syntax. An RFC would still be needed before this could have any chance at stabilization, and it might be removed at any point. But I'd really like to have it in nightly at least to ensure it works well with try_trait_v2, especially as we refactor the traits.
2022-04-29Fix duplicate directory separator in --remap-path-prefix.Michael Woerister-1/+93
2022-04-22extend `EventArgRecorder` into span-aware `SpannedEventArgRecorder`Rémy Rakic-0/+37
The self-profiler's `EventArgRecorder` is general-purpose in its ability to record Strings (and `rustc_span` depends on the crate its defined in, `rustc_data_structure`). Some generic activities could use recording locations where they happen in the user's code: to allow e.g. to track macro expansions and diagnose performance issues there. This adds a `SpannedEventArgRecorder` that can record an argument given as a span, rather than a String, since turning spans into Strings can be tricky if you're not happy with its default Debug output. This way the recorder can have a `record_arg_spanned` method which will do that.
2022-04-20Auto merge of #96082 - michaelwoerister:less_impl_stable_hash_via_hash, ↵bors-2/+1
r=compiler-errors incr. comp.: Don't export impl_stable_hash_via_hash!() and warn about using it. Fixes https://github.com/rust-lang/rust/issues/96013.
2022-04-19Rollup merge of #95740 - Amanieu:kreg0, r=nagisaDylan DPC-0/+1
asm: Add a kreg0 register class on x86 which includes k0 Previously we only exposed a kreg register class which excludes the k0 register since it can't be used in many instructions. However k0 is a valid register and we need to have a way of marking it as clobbered for clobber_abi. Fixes #94977
2022-04-19asm: Add a kreg0 register class on x86 which includes k0Amanieu d'Antras-0/+1
Previously we only exposed a kreg register class which excludes the k0 register since it can't be used in many instructions. However k0 is a valid register and we need to have a way of marking it as clobbered for clobber_abi. Fixes #94977
2022-04-19Rollup merge of #96142 - cjgillot:no-crate-def-index, r=petrochenkovDylan DPC-2/+13
Stop using CRATE_DEF_INDEX outside of metadata encoding. `CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want. We should not manipulate raw `DefIndex` outside of metadata encoding.
2022-04-19incr. comp.: Don't export impl_stable_hash_via_hash!() and warn about using it.Michael Woerister-2/+1
2022-04-17Auto merge of #96016 - Aaron1011:hash-name-cleanup, r=cjgillotbors-10/+0
Remove last vestiges of skippng ident span hashing This removes a comment that no longer applies, and properly hashes the full ident for path segments.
2022-04-17Stop using CRATE_DEF_INDEX.Camille GILLOT-2/+13
`CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want.
2022-04-16Rollup merge of #95961 - RalfJung:gather-scatter, r=workingjubileeDylan DPC-0/+1
implement SIMD gather/scatter via vector getelementptr Fixes https://github.com/rust-lang/portable-simd/issues/271 However, I don't *really* know what I am doing here... Cc ``@workingjubilee`` ``@calebzulawski`` I didn't do anything for cranelift -- ``@bjorn3`` not sure if it's okay for that backend to temporarily break. I'm happy to cherry-pick a patch that adds cranelift support. :)
2022-04-15Rollup merge of #94461 - jhpratt:2024-edition, r=pnkfelixDylan DPC-2/+35
Create (unstable) 2024 edition [On Zulip](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Deprecating.20macro.20scoping.20shenanigans/near/272860652), there was a small aside regarding creating the 2024 edition now as opposed to later. There was a reasonable amount of support and no stated opposition. This change creates the 2024 edition in the compiler and creates a prelude for the 2024 edition. There is no current difference between the 2021 and 2024 editions. Cargo and other tools will need to be updated separately, as it's not in the same repository. This change permits the vast majority of work towards the next edition to proceed _now_ instead of waiting until 2024. For sanity purposes, I've merged the "hello" UI tests into a single file with multiple revisions. Otherwise we'd end up with a file per edition, despite them being essentially identical. ````@rustbot```` label +T-lang +S-waiting-on-review Not sure on the relevant team, to be honest.
2022-04-13Auto merge of #95981 - martingms:invert-line-offset-parsing, r=nnethercotebors-11/+14
Optimize `<SourceFile as Decodable>::decode` It showed up as a hot-ish function in a callgrind profile of the `await-call-tree` benchmark crate. Provides some moderate speedups to compilation of some of the smaller benchmarks: #### Primary benchmarks Benchmark | Profile | Scenario | % Change | Significance Factor? -- | -- | -- | -- | -- helloworld | check | full | -1.81% | 9.03x helloworld | check | incr-unchanged | -1.80% | 8.99x helloworld | check | incr-full | -1.59% | 7.97x helloworld | check | incr-patched: println | -1.57% | 7.86x #### Secondary benchmarks <div class="category-title"></div> Benchmark | Profile | Scenario | % Change | Significance Factor? -- | -- | -- | -- | -- unify-linearly | check | incr-unchanged | -1.55% | 7.74x unify-linearly | check | incr-patched: dummy fn | -1.42% | 7.08x await-call-tree | check | incr-unchanged | -1.27% | 6.35x await-call-tree | debug | incr-unchanged | -1.19% | 5.95x await-call-tree | opt | incr-unchanged | -1.19% | 5.94x issue-46449 | check | incr-unchanged | -1.08% | 5.39x issue-46449 | check | incr-patched: u8 3072 | -1.00% | 5.00x structopt-0.3.26 | check | incr-unchanged | -0.94% | 4.72x structopt-0.3.26 | opt | incr-unchanged | -0.92% | 4.60x structopt-0.3.26 | debug | incr-unchanged | -0.92% | 4.59x issue-46449 | check | full | -0.89% | 4.46x structopt-0.3.26 | check | full | -0.83% | 4.17x structopt-0.3.26 | debug | full | -0.78% | 3.88x structopt-0.3.26 | opt | full | -0.76% | 3.81x unify-linearly | check | full | -0.75% | 3.74x projection-caching | check | incr-unchanged | -0.74% | 3.70x issue-46449 | check | incr-patched: u32 3072 | -0.70% | 3.50x issue-46449 | check | incr-patched: empty 3072 | -0.68% | 3.41x structopt-0.3.26 | check | incr-full | -0.68% | 3.40x wf-projection-stress-65510 | check | incr-unchanged | -0.68% | 3.39x issue-46449 | check | incr-patched: static str 6144 | -0.67% | 3.37x wf-projection-stress-65510 | debug | incr-unchanged | -0.67% | 3.33x wf-projection-stress-65510 | opt | incr-unchanged | -0.66% | 3.31x issue-46449 | check | incr-patched: io error 6144 | -0.66% | 3.29x unify-linearly | check | incr-full | -0.65% | 3.26x issue-46449 | check | incr-full | -0.65% | 3.25x structopt-0.3.26 | debug | incr-full | -0.64% | 3.18x structopt-0.3.26 | opt | incr-full | -0.63% | 3.17x issue-46449 | debug | incr-unchanged | -0.61% | 3.06x issue-46449 | opt | incr-unchanged | -0.61% | 3.03x await-call-tree | check | full | -0.60% | 2.99x issue-88862 | check | incr-unchanged | -0.58% | 2.91x deep-vector | debug | full | 0.57% | 2.83x await-call-tree | check | incr-full | -0.52% | 2.59x tt-muncher | opt | full | -0.52% | 2.58x issue-58319 | check | incr-unchanged | -0.50% | 2.52x await-call-tree | debug | full | -0.50% | 2.49x await-call-tree | opt | full | -0.49% | 2.45x deep-vector | debug | incr-patched: println | 0.47% | 2.37x await-call-tree | debug | incr-full | -0.45% | 2.26x await-call-tree | opt | incr-full | -0.44% | 2.18x issue-88862 | check | full | -0.41% | 2.06x mockall-0.11.0 | check | incr-unchanged | -0.38% | 1.90x regression-31157 | check | incr-unchanged | -0.37% | 1.86x wf-projection-stress-65510 | opt | full | -0.36% | 1.80x deunicode-1.3.1 | check | incr-unchanged | -0.35% | 1.76x unify-linearly | debug | incr-patched: dummy fn | -0.35% | 1.74x mockall-0.11.0 | check | full | -0.35% | 1.73x unify-linearly | debug | incr-unchanged | -0.34% | 1.69x deunicode-1.3.1 | check | full | -0.33% | 1.63x token-stream-stress | check | full | -0.32% | 1.62x token-stream-stress | check | incr-full | -0.32% | 1.59x token-stream-stress | check | incr-unchanged | -0.32% | 1.59x regression-31157 | check | incr-patched: println | -0.31% | 1.57x wf-projection-stress-65510 | check | full | -0.31% | 1.54x deeply-nested-multi | check | incr-unchanged | -0.31% | 1.53x mockall-0.11.0 | opt | incr-unchanged | -0.30% | 1.50x r? `@nnethercote`
2022-04-13Remove last vestiges of skippng ident span hashingAaron Hill-10/+0
This removes a comment that no longer applies, and properly hashes the full ident for path segments.
2022-04-13Use .extend(..) instead of push()-ing in loopMartin Gammelsæter-18/+12
A bit less readable but more compact, and maybe faster? We'll see.
2022-04-12Remove NodeIdHashingMode.Camille GILLOT-1/+1
2022-04-12Optimize line offset parsing in <SourceFile as Decodable>::decodeMartin Gammelsæter-11/+20
By inverting parsing loop, avoiding continually re-checking bytes_per_diff.
2022-04-12add simd_arith_offset intrinsicsRalf Jung-0/+1