about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2023-09-08debuginfo: add compiler option to allow compressed debuginfo sectionsAugie Fackler-7/+115
LLVM already supports emitting compressed debuginfo. In debuginfo=full builds, the debug section is often a large amount of data, and it typically compresses very well (3x is not unreasonable.) We add a new knob to allow debuginfo to be compressed when the matching LLVM functionality is present. Like clang, if a known-but-disabled compression mechanism is requested, we disable compression and emit uncompressed debuginfo sections. The API is different enough on older LLVMs we just pretend the support is missing on LLVM older than 16.
2023-09-08lto: handle Apple platforms correctly by eliding __LLVM, from section nameAugie Fackler-1/+4
2023-09-08lto: load bitcode sections by nameAugie Fackler-16/+86
Upstream change llvm/llvm-project@6b539f5eb8ef1d3a3c87873caa2dbd5147e1adbd changed `isSectionBitcode` works and it now only respects `.llvm.lto` sections instead of also `.llvmbc`, which it says was never intended to be used for LTO. We instead load sections by name, and sniff for raw bitcode by hand. r? @nikic @rustbot label: +llvm-main
2023-09-08Auto merge of #115372 - RalfJung:abi-assert-eq, r=davidtwcobors-149/+396
add rustc_abi(assert_eq) to test some guaranteed or at least highly expected ABI compatibility guarantees This new repr(transparent) test is super useful, it would have found https://github.com/rust-lang/rust/issues/115336 and found https://github.com/rust-lang/rust/issues/115404, https://github.com/rust-lang/rust/issues/115481, https://github.com/rust-lang/rust/issues/115509.
2023-09-08Auto merge of #113492 - nebulark:pr_96475, r=petrochenkovbors-1/+87
Add CL and CMD into to pdb debug info Partial fix for https://github.com/rust-lang/rust/issues/96475 The Arg0 and CommandLineArgs of the MCTargetOptions cpp class are not set within https://github.com/rust-lang/rust/blob/bb548f964572f7fe652716f5897d9050a31c936e/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp#L378 This causes LLVM to not neither output any compiler path (cl) nor the arguments that were used when invoking it (cmd) in the PDB file. This fix adds the missing information to the target machine so LLVM can use it.
2023-09-08turns out Layout has some more things to worry about -- move ABI comparison ↵Ralf Jung-25/+38
into helper function like is_bool, and some special magic extra fields
2023-09-08the wasm ABI behavior is a bugRalf Jung-11/+15
2023-09-08also ensure that size and alignment are the sameRalf Jung-3/+7
2023-09-08accept some differences for rustc_abi(assert_eq), so that we can test more ↵Ralf Jung-63/+76
things to be compatible
2023-09-08Rollup merge of #115634 - nnethercote:IntVid-FloatVid, r=oli-obkMatthias Krüger-26/+14
Use `newtype_index` for `IntVid` and `FloatVid`. `TyVid` already uses `newtype_index`.
2023-09-08Rollup merge of #115629 - compiler-errors:sugg-deref-unsize, r=oli-obkMatthias Krüger-12/+22
Don't suggest dereferencing to unsized type Rudimentary check that the self type is Sized. I don't really like any of this diagnostics code -- it's really messy and also really prone to false positives and negatives, but oh well. Fixes #115569
2023-09-08Rollup merge of #115624 - compiler-errors:rtn-path, r=WaffleLapkinMatthias Krüger-0/+11
Print the path of a return-position impl trait in trait when `return_type_notation` is enabled When we're printing a return-position impl trait in trait, we usually just print it like an opaque. This is *usually* fine, but can be confusing when using `return_type_notation`. Print the path of the method from where the RPITIT originates when this feature gate is enabled.
2023-09-08Auto merge of #115608 - RalfJung:fn-arg-validity, r=oli-obkbors-0/+7
miri: catch function calls where the argument is caller-invalid / the return value callee-invalid When doing a type-changing copy, we must validate the data both at the old and new type. Fixes https://github.com/rust-lang/miri/issues/3017
2023-09-08Auto merge of #115586 - Zalathar:query, r=cjgillotbors-72/+51
coverage: Simplify the `coverageinfo` query The `coverageinfo` query walks through a `mir::Body`'s statements to find the total number of coverage counter IDs and coverage expression IDs that have been used, as this information is needed by coverage codegen. This PR makes 3 nice simplifications to that query: - Extract a common iterator over coverage statements, shared by both coverage-related queries - Simplify the query's visitor from two passes to just one pass - Explicitly track the highest seen IDs in the visitor, and only convert to a count right at the end I also updated some related comments. Some had been invalidated by these changes, while others had already been invalidated by previous coverage changes.
2023-09-08Add missing Debuginfo to PDB debug file on windows.Florian Schmiderer-1/+87
Set Arg0 and CommandLineArgs in MCTargetoptions so LLVM outputs correct CL and CMD in LF_DEBUGINFO instead of empty/invalid values.
2023-09-07Auto merge of #115527 - oli-obk:drop_maybe_uninit_in_const, r=lcnrbors-2/+22
Don't require `Drop` for `[PhantomData<T>; N]` where `N` and `T` are generic, if `T` requires `Drop` fixes https://github.com/rust-lang/rust/issues/115403 fixes https://github.com/rust-lang/rust/issues/115410 This was accidentally regressed in https://github.com/rust-lang/rust/pull/114134, because it was accidentally stabilized in #102204 (cc `@rust-lang/lang,` seems like an innocent stabilization, considering this PR is more of a bugfix than a feature). While we have a whole month to beta backport this change before the regression hits stable, I'd still prefer not to go through an FCP on this PR (which fixes a regression), if T-lang wants an FCP, I can can open an issue about the change itself.
2023-09-07Don't require `Drop` for `[PhantomData<T>; N]` where `N` and `T` are ↵Oli Scherer-2/+22
generic, if `T` requires `Drop`
2023-09-07Auto merge of #114183 - Urgau:stabilize-print-with-path, r=oli-obkbors-6/+0
Stabilize `PATH` option for `--print KIND=PATH` This PR propose stabilizing the `PATH` option for `--print KIND=PATH`. This option was previously added in https://github.com/rust-lang/rust/pull/113780 (as insta-stable before being un-stablized in https://github.com/rust-lang/rust/pull/114139). Description of the `PATH` option: > A filepath may optionally be specified for each requested information kind, in the format `--print KIND=PATH`, just like for `--emit`. When a path is specified, information will be written there instead of to stdout. ------ Description of the original PR [\[link\]](https://github.com/rust-lang/rust/pull/113780#issue-1807080607): > **Support --print KIND=PATH command line syntax** > > As is already done for `--emit KIND=PATH` and `-L KIND=PATH`. > > In the discussion of https://github.com/rust-lang/rust/pull/110785, it was pointed out that `--print KIND=PATH` is nicer than trying to apply the single global `-o path` to `--print`'s output, because in general there can be multiple print requests within a single rustc invocation, and anyway `-o` would already be used for a different meaning in the case of `link-args` and `native-static-libs`. > > I am interested in using `--print cfg=PATH` in Buck2. Currently Buck2 works around the lack of support for `--print KIND=PATH` by [indirecting through a Python wrapper script](https://github.com/facebook/buck2/blob/d43cf3a51a31f00be2c2248e78271b0fef0452b4/prelude/rust/tools/get_rustc_cfg.py) to redirect rustc's stdout into the location dictated by the build system. > > From skimming Cargo's usages of `--print`, it definitely seems like it would benefit from `--print KIND=PATH` too. Currently it is working around the lack of this by inserting `--crate-name=___ --print=crate-name` so that it can look for a line containing `___` as a delimiter between the 2 other `--print` informations it actually cares about. This is commented as a "HACK" and "abuse". https://github.com/rust-lang/cargo/blob/31eda6f7c360d9911f853b3014e057db61238f3e/src/cargo/core/compiler/build_context/target_info.rs#L242 ----- cc `@dtolnay` r? `@jackh726`
2023-09-07Stabilize `PATH` option for `--print KIND=PATH`Urgau-6/+0
Description of the `PATH` option: > A filepath may optionally be specified for each requested information > kind, in the format `--print KIND=PATH`, just like for `--emit`. When > a path is specified, information will be written there instead of to > stdout.
2023-09-07Auto merge of #115602 - oli-obk:lower_intrinsics, r=petrochenkovbors-29/+30
Don't report any errors in `lower_intrinsics`. Intrinsics should have been type checked earlier. This is part of moving all mir-opt diagnostics early enough so that they are reliably emitted even in check builds: https://github.com/rust-lang/rust/issues/49292#issuecomment-1692212095
2023-09-07coverage: In the visitor, track max counter/expression IDs without +1Zalathar-25/+25
This makes the visitor track the highest seen counter/expression IDs directly, and only add +1 (to convert to a vector length) at the very end.
2023-09-07coverage: Simplify the `coverageinfo` query to a single passZalathar-30/+13
2023-09-07coverage: Extract a common iterator over a function's coverage statementsZalathar-23/+19
Both of the coverage queries can now use this one helper function to iterate over all of the `mir::Coverage` payloads in the statements of a `mir::Body`.
2023-09-07Use `newtype_index` for `IntVid` and `FloatVid`.Nicholas Nethercote-26/+14
`TyVid` already uses `newtype_index`.
2023-09-07Auto merge of #115582 - compiler-errors:refine-yeet, r=oli-obkbors-5/+390
Implement refinement lint for RPITIT Implements a lint that warns against accidentally refining an RPITIT in an implementation. This is not a hard error, and can be suppressed with `#[allow(refining_impl_trait)]`, since this behavior may be desirable -- the lint just serves as an acknowledgement from the impl author that they understand that the types they write in the implementation are an API guarantee. This compares bounds syntactically, not semantically -- semantic implication is more difficult and essentially relies on adding the ability to keep the RPITIT hidden in the trait system so that things can be proven about the type that shows up in the impl without its own bounds leaking through, either via a new reveal mode or something else. This was experimentally implemented in #111931. Somewhat opinionated choices: 1. Putting the lint behind `refining_impl_trait` rather than a blanket `refine` lint. This could be changed, but I like keeping the lint specialized to RPITITs so the explanation can be tailored to it. 2. This PR does not include the `#[refine]` attribute or the feature gate, since it's kind of orthogonal and can be added in a separate PR. r? `@oli-obk`
2023-09-07add support for rustc_abi(assert_eq) and use it to test some ↵Ralf Jung-2/+90
repr(transparent) cases
2023-09-07extend comments around PassMode::DirectRalf Jung-2/+46
2023-09-07Ensure that dyn trait bounds stay sortedMichael Goulet-11/+8
2023-09-07Don't suggest dereferencing to unsized typeMichael Goulet-1/+14
2023-09-07Auto merge of #115616 - bjorn3:sync_cg_clif-2023-09-06, r=bjorn3bors-8/+10
Sync rustc_codegen_cranelift Not much changed this time. Mostly doing this sync to make it easier to run the entire test suite on the in-tree version. r? `@ghost` `@rustbot` label +A-codegen +A-cranelift +T-compiler
2023-09-07Auto merge of #110050 - saethlin:better-u32-encoding, r=nnethercotebors-45/+399
Use a specialized varint + bitpacking scheme for DepGraph encoding The previous scheme here uses leb128 to encode the edge tables that represent the incr comp dependency graph. The problem with that scheme is that leb128 has overhead for larger values, and generally relies on the distribution of encoded values being heavily skewed towards smaller values. That is definitely not the case for a dep node index, since they are handed out sequentially and the whole range is covered, the distribution is actually biased in the opposite direction: Most dep nodes are large. This PR implements a different varint encoding scheme. Instead of applying varint encoding to individual dep node indices (which is extremely branchy) we now apply it per node. While being built, each node now stores its edges in a `SmallVec` with a bit of extra logic to track the max value of each edge. Then we varint encode the whole batch. This is a gamble: We save on space by only claiming 2 bits per node instead of ~3 bits per edge which is a nice savings but needs to balance out with the space overhead that a single large index in a node with a lot of edges will encode unnecessary bytes in each of that node's edge indices. Then, to keep the runtime overhead of this encoding scheme down we deserialize our indices by loading 4 bytes for each then masking off the bytes that are't ours. This is much less code and branches than leb128, but relies on having some readable bytes past the end of each edge list. We explicitly add such padding to the in-memory data during decoding. And we also do this decoding lazily, turning a dense on-disk encoding into a peak memory reduction. Then we apply a bit-packing scheme; since in https://github.com/rust-lang/rust/pull/115391 we now have unused bits on `DepKind`, we use those unused bits (currently there are 7!) to store the 2 bits that we need for the byte width of the edges in each node, then use the remaining bits to store the length of the edge list, if it fits. r? `@nnethercote`
2023-09-07Print the path of an RPITIT in RTNMichael Goulet-0/+11
2023-09-07Add noteMichael Goulet-0/+2
2023-09-07Don't emit refining_impl_trait for private itemsMichael Goulet-1/+29
2023-09-06Add comments with the same level of detail as the PR descriptionBen Kimock-12/+54
2023-09-07Use self instead of the actual self tyMichael Goulet-3/+15
2023-09-07Implement refinement lint for RPITITMichael Goulet-5/+348
2023-09-07Auto merge of #115166 - Urgau:invalid_ref_casting-invalid-unsafecell-usage, ↵bors-5/+40
r=est31 Lint on invalid usage of `UnsafeCell::raw_get` in reference casting This PR proposes to take into account `UnsafeCell::raw_get` method call for non-Freeze types for the `invalid_reference_casting` lint. The goal of this is to catch those kind of invalid reference casting: ```rust fn as_mut<T>(x: &T) -> &mut T { unsafe { &mut *std::cell::UnsafeCell::raw_get(x as *const _ as *const _) } //~^ ERROR casting `&T` to `&mut T` is undefined behavior } ``` r? `@est31`
2023-09-06Auto merge of #115580 - eduardosm:stdarch-intrinsics, r=davidtwco,bjorn3bors-248/+0
Update stdarch submodule and remove special handling in cranelift codegen for some AVX and SSE2 LLVM intrinsics https://github.com/rust-lang/stdarch/pull/1463 reimplemented some x86 intrinsics to avoid using some x86-specific LLVM intrinsics: * Store unaligned (`_mm*_storeu_*`) use `<*mut _>::write_unaligned` instead of `llvm.x86.*.storeu.*`. * Shift by immediate (`_mm*_s{ll,rl,ra}i_epi*`) use `if` (srl, sll) or `min` (sra) to simulate the behaviour when the RHS is out of range. RHS is constant, so the `if`/`min` will be optimized away. This PR updates the stdarch submodule to pull these changes and removes special handling for those LLVM intrinsics from cranelift codegen. I left gcc codegen untouched because there are some autogenerated lists.
2023-09-06Auto merge of #114946 - anforowicz:generic-fix-for-asan-lto, r=tmiaskobors-0/+7
Preserve ASAN-related symbols during LTO. Fixes https://github.com/rust-lang/rust/issues/113404
2023-09-06Merge commit 'dda103b1e33c4902deca8bccf614991ada781fa6' into ↵bjorn3-8/+10
sync_cg_clif-2023-09-06
2023-09-06Auto merge of #115615 - matthiaskrgr:rollup-49fosdf, r=matthiaskrgrbors-25/+60
Rollup of 9 pull requests Successful merges: - #114511 (Remove the unhelpful let binding diag comes from FormatArguments) - #115473 (Add explanatory note to 'expected item' error) - #115574 (Replace `rustc_data_structures` dependency with `rustc_index` in `rustc_parse_format`) - #115578 (Clarify cryptic comments) - #115587 (fix #115348) - #115596 (A small change) - #115598 (Fix log formatting in bootstrap) - #115605 (Better Debug for `Ty` in smir) - #115614 (Fix minor grammar typo) r? `@ghost` `@rustbot` modify labels: rollup
2023-09-06Rollup merge of #115605 - ouz-a:smir_better_debug, r=oli-obkMatthias Krüger-1/+8
Better Debug for `Ty` in smir Similar to what I did here https://github.com/rust-lang/rust/pull/115534. r? ``@oli-obk``
2023-09-06Rollup merge of #115596 - nnethercote:two-small-changes, r=lqdMatthias Krüger-1/+1
A small change A small change I made while poking around the code. r? `@lqd`
2023-09-06Rollup merge of #115587 - mojave2:issue-115348, r=oli-obkMatthias Krüger-1/+1
fix #115348 fix #115348 It looks that: - In `rustc_mir_build::build`, the body of function will not be built, when the `tcx.check_match(def)` fails due to `non-exhaustive patterns` - In `rustc_mir_transform::check_unsafety`, the `UnsafetyChecker` collects all `used_unsafe_blocks` in the MIR of a function, and the `UnusedUnsafeVisitor` will visit all `UnsafeBlock`s in the HIR and collect `unused_unsafes`, which are not contained in `used_unsafe_blocks`, and report `unnecessary_unsafe`s - So the unsafe block in the issue example code will be reported as `unnecessary_unsafe`.
2023-09-06Rollup merge of #115578 - ouz-a:rustc_clarify, r=oli-obkMatthias Krüger-3/+3
Clarify cryptic comments Clarifies some unclear comments that lurked in the compiler. r? ``@oli-obk``
2023-09-06Rollup merge of #115574 - Veykril:rustc_parse_format-dep, r=NilstriebMatthias Krüger-2/+2
Replace `rustc_data_structures` dependency with `rustc_index` in `rustc_parse_format` `rustc_data_structures` is only used for the `static_assert_size` macro, yet that is defined in `rustc_index` and merely re-exported. `rustc_index` is a lot more lightweight than `rustc_data_structures` which would make this a lot more reusable for rust-analyzer.
2023-09-06Rollup merge of #115473 - gurry:113110-expected-item, r=compiler-errorsMatthias Krüger-4/+8
Add explanatory note to 'expected item' error Fixes #113110 It changes the diagnostic from this: ``` error: expected item, found `5` --> ../test.rs:1:1 | 1 | 5 | ^ expected item ``` to this: ``` error: expected item, found `5` --> ../test.rs:1:1 | 1 | 5 | ^ expected item | = note: items are things that can appear at the root of a module = note: for a full list see https://doc.rust-lang.org/reference/items.html ```
2023-09-06Rollup merge of #114511 - chenyukang:yukang-fix-114374-fmt-args, r=b-naberMatthias Krüger-13/+37
Remove the unhelpful let binding diag comes from FormatArguments Fixes #114374
2023-09-06Auto merge of #115252 - cjgillot:mir-composite, r=davidtwcobors-284/+250
Represent MIR composite debuginfo as projections instead of aggregates Composite debuginfo for MIR is currently represented as ``` debug name => Type { projection1 => place1, projection2 => place2 }; ``` ie. a single `VarDebugInfo` object with that name, and its value a `VarDebugInfoContents::Composite`. This PR proposes to reverse the representation to be ``` debug name.projection1 => place1; debug name.projection2 => place2; ``` ie. multiple `VarDebugInfo` objects with each their projection. This simplifies the handling of composite debuginfo by the compiler by avoiding weird nesting. Based on https://github.com/rust-lang/rust/pull/115139