about summary refs log tree commit diff
path: root/compiler/rustc_codegen_gcc
AgeCommit message (Collapse)AuthorLines
2024-05-06Refactor float `Primitive`s to a separate `Float` typebeetrees-6/+3
2024-05-03Auto merge of #123441 - saethlin:fixed-len-file-names, r=oli-obkbors-2/+3
Stabilize the size of incr comp object file names The current implementation does not produce stable-length paths, and we create the paths in a way that makes our allocation behavior is nondeterministic. I think `@eddyb` fixed a number of other cases like this in the past, and this PR fixes another one. Whether that actually matters I have no idea, but we still have bimodal behavior in rustc-perf and the non-uniformity in `find` and `ls` was bothering me. I've also removed the truncation of the mangled CGU names. Before this PR incr comp paths look like this: ``` target/debug/incremental/scratch-38izrrq90cex7/s-gux6gz0ow8-1ph76gg-ewe1xj434l26w9up5bedsojpd/261xgo1oqnd90ry5.o ``` And after, they look like this: ``` target/debug/incremental/scratch-035omutqbfkbw/s-gux6borni0-16r3v1j-6n64tmwqzchtgqzwwim5amuga/55v2re42sztc8je9bva6g8ft3.o ``` On the one hand, I'm sure this will break some people's builds because they're on Windows and only a few bytes from the path length limit. But if we're that seriously worried about the length of our file names, I have some other ideas on how to make them smaller. And last time I deleted some hash truncations from the compiler, there was a huge drop in the number if incremental compilation ICEs that were reported: https://github.com/rust-lang/rust/pull/110367https://github.com/rust-lang/rust/pull/110367 --- Upon further reading, this PR actually fixes a bug. This comment says the CGU names are supposed to be a fixed-length hash, and before this PR they aren't: https://github.com/rust-lang/rust/blob/ca7d34efa94afe271accf2bd3d44152a5bd6fff1/compiler/rustc_monomorphize/src/partitioning.rs#L445-L448
2024-05-02Rollup merge of #124624 - WaffleLapkin:old_unit, r=fmeaseMatthias Krüger-2/+2
Use `tcx.types.unit` instead of `Ty::new_unit(tcx)` I don't think there is any need for the function, given that we can just access the `.types`, similarly to all other primitives?
2024-05-02Inline & delete `Ty::new_unit`, since it's just a field accessWaffle Lapkin-2/+2
2024-05-01Step bootstrap cfgsMark Rousskov-2/+0
2024-04-24Error on using `yield` without also using `#[coroutine]` on the closureOli Scherer-2/+2
And suggest adding the `#[coroutine]` to the closure
2024-04-24Auto merge of #122053 - erikdesjardins:alloca, r=nikicbors-13/+7
Stop using LLVM struct types for alloca The alloca type has no semantic meaning, only the size (and alignment, but we specify it explicitly) matter. Using `[N x i8]` is a more direct way to specify that we want `N` bytes, and avoids relying on LLVM's struct layout. It is likely that a future LLVM version will change to an untyped alloca representation. Split out from #121577. r? `@ghost`
2024-04-23Rollup merge of #124003 - WaffleLapkin:dellvmization, r=scottmcm,RalfJung,antoyoMatthias Krüger-4/+5
Dellvmize some intrinsics (use `u32` instead of `Self` in some integer intrinsics) This implements https://github.com/rust-lang/compiler-team/issues/693 minus what was implemented in #123226. Note: I decided to _not_ change `shl`/... builder methods, as it just doesn't seem worth it. r? ``@scottmcm``
2024-04-22Stabilize the size of incr comp object file namesBen Kimock-2/+3
2024-04-20Rollup merge of #123967 - RalfJung:static_mut_refs, r=Nilstrieb许杰友 Jieyou Xu (Joe)-4/+2
static_mut_refs: use raw pointers to remove the remaining FIXME Using `SyncUnsafeCell` would not make a lot of sense IMO.
2024-04-20Fixup `rustc_codegen_gcc` test signatureMaybe Waffle-4/+5
2024-04-19Auto merge of #117919 - daxpedda:wasm-c-abi, r=wesleywiserbors-2/+14
Introduce perma-unstable `wasm-c-abi` flag Now that `wasm-bindgen` v0.2.88 supports the spec-compliant C ABI, the idea is to switch to that in a future version of Rust. In the meantime it would be good to let people test and play around with it. This PR introduces a new perma-unstable `-Zwasm-c-abi` compiler flag, which switches to the new spec-compliant C ABI when targeting `wasm32-unknown-unknown`. Alternatively, we could also stabilize this and then deprecate it when we switch. I will leave this to the Rust maintainers to decide. This is a companion PR to #117918, but they could be merged independently. MCP: https://github.com/rust-lang/compiler-team/issues/703 Tracking issue: https://github.com/rust-lang/rust/issues/122532
2024-04-15static_mut_refs: use raw pointers to remove the remaining FIXMERalf Jung-4/+2
2024-04-12restore location in gcc alloca codegenErik Desjardins-1/+7
2024-04-11use [N x i8] for alloca typesErik Desjardins-19/+7
2024-04-11Put `PlaceValue` into `OperandValue::Ref`, rather than 3 tuple fieldsScott McMurray-6/+12
2024-04-11Make `PlaceRef` hold a `PlaceValue` for the non-layout fields (like ↵Scott McMurray-18/+18
`OperandRef` does)
2024-04-06Save/restore more items in cache with incremental compilationMichael Baikov-0/+2
2024-04-05Rollup merge of #122334 - GuillaumeGomez:vendor-cg_gcc, r=Mark-SimulacrumGuillaume Gomez-5/+7
Vendor rustc_codegen_gcc I used https://github.com/rust-lang/rust/pull/115274 as base for this update. r? `@bjorn3`
2024-04-02Auto merge of #118310 - scottmcm:three-way-compare, r=davidtwcobors-0/+4
Add `Ord::cmp` for primitives as a `BinOp` in MIR Update: most of this OP was written months ago. See https://github.com/rust-lang/rust/pull/118310#issuecomment-2016940014 below for where we got to recently that made it ready for review. --- There are dozens of reasonable ways to implement `Ord::cmp` for integers using comparison, bit-ops, and branches. Those differences are irrelevant at the rust level, however, so we can make things better by adding `BinOp::Cmp` at the MIR level: 1. Exactly how to implement it is left up to the backends, so LLVM can use whatever pattern its optimizer best recognizes and cranelift can use whichever pattern codegens the fastest. 2. By not inlining those details for every use of `cmp`, we drastically reduce the amount of MIR generated for `derive`d `PartialOrd`, while also making it more amenable to MIR-level optimizations. Having extremely careful `if` ordering to μoptimize resource usage on broadwell (#63767) is great, but it really feels to me like libcore is the wrong place to put that logic. Similarly, using subtraction [tricks](https://graphics.stanford.edu/~seander/bithacks.html#CopyIntegerSign) (#105840) is arguably even nicer, but depends on the optimizer understanding it (https://github.com/llvm/llvm-project/issues/73417) to be practical. Or maybe [bitor is better than add](https://discourse.llvm.org/t/representing-in-ir/67369/2?u=scottmcm)? But maybe only on a future version that [has `or disjoint` support](https://discourse.llvm.org/t/rfc-add-or-disjoint-flag/75036?u=scottmcm)? And just because one of those forms happens to be good for LLVM, there's no guarantee that it'd be the same form that GCC or Cranelift would rather see -- especially given their very different optimizers. Not to mention that if LLVM gets a spaceship intrinsic -- [which it should](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Suboptimal.20inlining.20in.20std.20function.20.60binary_search.60/near/404250586) -- we'll need at least a rustc intrinsic to be able to call it. As for simplifying it in Rust, we now regularly inline `{integer}::partial_cmp`, but it's quite a large amount of IR. The best way to see that is with https://github.com/rust-lang/rust/commit/8811efa88b25b5e41d63850e6047e8257c677858#diff-d134c32d028fbe2bf835fef2df9aca9d13332dd82284ff21ee7ebf717bfa4765R113 -- I added a new pre-codegen MIR test for a simple 3-tuple struct, and this PR change it from 36 locals and 26 basic blocks down to 24 locals and 8 basic blocks. Even better, as soon as the construct-`Some`-then-match-it-in-same-BB noise is cleaned up, this'll expose the `Cmp == 0` branches clearly in MIR, so that an InstCombine (#105808) can simplify that to just a `BinOp::Eq` and thus fix some of our generated code perf issues. (Tracking that through today's `if a < b { Less } else if a == b { Equal } else { Greater }` would be *much* harder.) --- r? `@ghost` But first I should check that perf is ok with this ~~...and my true nemesis, tidy.~~
2024-03-29stabilize ptr.is_aligned, move ptr.is_aligned_to to a new feature gateAria Beingessner-2/+2
This is an alternative to #121920
2024-03-29Auto merge of #122671 - Mark-Simulacrum:const-panic-msg, r=Nilstriebbors-0/+30
Codegen const panic messages as function calls This skips emitting extra arguments at every callsite (of which there can be many). For a librustc_driver build with overflow checks enabled, this cuts 0.7MB from the resulting shared library (see [perf]). A sample improvement from nightly: ``` leaq str.0(%rip), %rdi leaq .Lalloc_d6aeb8e2aa19de39a7f0e861c998af13(%rip), %rdx movl $25, %esi callq *_ZN4core9panicking5panic17h17cabb89c5bcc999E@GOTPCREL(%rip) ``` to this PR: ``` leaq .Lalloc_d6aeb8e2aa19de39a7f0e861c998af13(%rip), %rdi callq *_RNvNtNtCsduqIKoij8JB_4core9panicking11panic_const23panic_const_div_by_zero@GOTPCREL(%rip) ``` [perf]: https://perf.rust-lang.org/compare.html?start=a7e4de13c1785819f4d61da41f6704ed69d5f203&end=64fbb4f0b2d621ff46d559d1e9f5ad89a8d7789b&stat=instructions:u
2024-03-24Rollup merge of #122937 - Zalathar:unbox, r=oli-obkMatthias Krüger-2/+2
Unbox and unwrap the contents of `StatementKind::Coverage` The payload of coverage statements was historically a structure with several fields, so it was boxed to avoid bloating `StatementKind`. Now that the payload is a single relatively-small enum, we can replace `Box<Coverage>` with just `CoverageKind`. This patch also adds a size assertion for `StatementKind`, to avoid accidentally bloating it in the future. ``@rustbot`` label +A-code-coverage
2024-03-23Add+Use `mir::BinOp::Cmp`Scott McMurray-0/+4
2024-03-23CFI: Use Instance at callsitesMatthew Maurer-8/+11
We already use `Instance` at declaration sites when available to glean additional information about possible abstractions of the type in use. This does the same when possible at callsites as well. The primary purpose of this change is to allow CFI to alter how it generates type information for indirect calls through `Virtual` instances.
2024-03-23Unbox and unwrap the contents of `StatementKind::Coverage`Zalathar-2/+2
The payload of coverage statements was historically a structure with several fields, so it was boxed to avoid bloating `StatementKind`. Now that the payload is a single relatively-small enum, we can replace `Box<Coverage>` with just `CoverageKind`. This patch also adds a size assertion for `StatementKind`, to avoid accidentally bloating it in the future.
2024-03-23Auto merge of #119552 - krtab:dead_code_priv_mod_pub_field, r=cjgillot,saethlinbors-0/+4
Replace visibility test with reachability test in dead code detection Fixes https://github.com/rust-lang/rust/issues/119545 Also included is a fix for an error now flagged by the lint
2024-03-22Make RawPtr take Ty and Mutbl separatelyMichael Goulet-12/+12
2024-03-22Codegen const panic messages as function callsMark Rousskov-0/+30
This skips emitting extra arguments at every callsite (of which there can be many). For a librustc_driver build with overflow checks enabled, this cuts 0.7MB from the resulting binary.
2024-03-19Auto merge of #122055 - compiler-errors:stabilize-atb, r=oli-obkbors-1/+1
Stabilize associated type bounds (RFC 2289) This PR stabilizes associated type bounds, which were laid out in [RFC 2289]. This gives us a shorthand to express nested type bounds that would otherwise need to be expressed with nested `impl Trait` or broken into several `where` clauses. ### What are we stabilizing? We're stabilizing the associated item bounds syntax, which allows us to put bounds in associated type position within other bounds, i.e. `T: Trait<Assoc: Bounds...>`. See [RFC 2289] for motivation. In all position, the associated type bound syntax expands into a set of two (or more) bounds, and never anything else (see "How does this differ[...]" section for more info). Associated type bounds are stabilized in four positions: * **`where` clauses (and APIT)** - This is equivalent to breaking up the bound into two (or more) `where` clauses. For example, `where T: Trait<Assoc: Bound>` is equivalent to `where T: Trait, <T as Trait>::Assoc: Bound`. * **Supertraits** - Similar to above, `trait CopyIterator: Iterator<Item: Copy> {}`. This is almost equivalent to breaking up the bound into two (or more) `where` clauses; however, the bound on the associated item is implied whenever the trait is used. See #112573/#112629. * **Associated type item bounds** - This allows constraining the *nested* rigid projections that are associated with a trait's associated types. e.g. `trait Trait { type Assoc: Trait2<Assoc2: Copy>; }`. * **opaque item bounds (RPIT, TAIT)** - This allows constraining associated types that are associated with the opaque without having to *name* the opaque. For example, `impl Iterator<Item: Copy>` defines an iterator whose item is `Copy` without having to actually name that item bound. The latter three are not expressible in surface Rust (though for associated type item bounds, this will change in #120752, which I don't believe should block this PR), so this does represent a slight expansion of what can be expressed in trait bounds. ### How does this differ from the RFC? Compared to the RFC, the current implementation *always* desugars associated type bounds to sets of `ty::Clause`s internally. Specifically, it does *not* introduce a position-dependent desugaring as laid out in [RFC 2289], and in particular: * It does *not* desugar to anonymous associated items in associated type item bounds. * It does *not* desugar to nested RPITs in RPIT bounds, nor nested TAITs in TAIT bounds. This position-dependent desugaring laid out in the RFC existed simply to side-step limitations of the trait solver, which have mostly been fixed in #120584. The desugaring laid out in the RFC also added unnecessary complication to the design of the feature, and introduces its own limitations to, for example: * Conditionally lowering to nested `impl Trait` in certain positions such as RPIT and TAIT means that we inherit the limitations of RPIT/TAIT, namely lack of support for higher-ranked opaque inference. See this code example: https://github.com/rust-lang/rust/pull/120752#issuecomment-1979412531. * Introducing anonymous associated types makes traits no longer object safe, since anonymous associated types are not nameable, and all associated types must be named in `dyn` types. This last point motivates why this PR is *not* stabilizing support for associated type bounds in `dyn` types, e.g, `dyn Assoc<Item: Bound>`. Why? Because `dyn` types need to have *concrete* types for all associated items, this would necessitate a distinct lowering for associated type bounds, which seems both complicated and unnecessary compared to just requiring the user to write `impl Trait` themselves. See #120719. ### Implementation history: Limited to the significant behavioral changes and fixes and relevant PRs, ping me if I left something out-- * #57428 * #108063 * #110512 * #112629 * #120719 * #120584 Closes #52662 [RFC 2289]: https://rust-lang.github.io/rfcs/2289-associated-type-bounds.html
2024-03-12Mark codegen_gcc fields used only on feature master as suchArthur Carcano-0/+4
The dead_code lint was previously eroneously missing those. Since this lint bug has been fixed, the unused fields need to be feature gated.
2024-03-12Some comment nitsOli Scherer-1/+1
2024-03-12Ensure nested allocations in statics do not get deduplicatedOli Scherer-1/+10
2024-03-12Make some functions private that are only ever used in the same moduleOli Scherer-1/+1
2024-03-12Check whether a static is mutable instead of passing it downOli Scherer-2/+2
2024-03-11Use published gccjit dependency instead of git repositoryGuillaume Gomez-5/+7
2024-03-11Rollup merge of #121840 - oli-obk:freeze, r=dtolnayJacob Pratt-1/+1
Expose the Freeze trait again (unstably) and forbid implementing it manually non-emoji version of https://github.com/rust-lang/rust/pull/121501 cc #60715 This trait is useful for generic constants (associated consts of generic traits). See the test (`tests/ui/associated-consts/freeze.rs`) added in this PR for a usage example. The builtin `Freeze` trait is the only way to do it, users cannot work around this issue. It's also a useful trait for building some very specific abstrations, as shown by the usage by the `zerocopy` crate: https://github.com/google/zerocopy/issues/941 cc ```@RalfJung``` T-lang signed off on reexposing this unstably: https://github.com/rust-lang/rust/pull/121501#issuecomment-1969827742
2024-03-11Auto merge of #122132 - nnethercote:diag-renaming3, r=nnethercotebors-3/+3
Diagnostic renaming 3 A sequel to https://github.com/rust-lang/rust/pull/121780. r? `@davidtwco`
2024-03-11Rename `IntoDiagnostic` as `Diagnostic`.Nicholas Nethercote-3/+3
To match `derive(Diagnostic)`. Also rename `into_diagnostic` as `into_diag`.
2024-03-10use Instance::expect_resolve() instead of unwraping Instance::resolve()Ralf Jung-4/+2
2024-03-10Introduce perma-unstable `wasm-c-abi` flagdaxpedda-2/+14
2024-03-10Fix cg_gcc mergeGuillaume Gomez-3/+5
2024-03-09Merge remote-tracking branch 'upstream/master' into HEADGuillaume Gomez-3/+29
2024-03-08Stabilize associated type boundsMichael Goulet-1/+1
2024-03-08Rollup merge of #119365 - nbdd0121:asm-goto, r=AmanieuMatthias Krüger-3/+28
Add asm goto support to `asm!` Tracking issue: #119364 This PR implements asm-goto support, using the syntax described in "future possibilities" section of [RFC2873](https://rust-lang.github.io/rfcs/2873-inline-asm.html#asm-goto). Currently I have only implemented the `label` part, not the `fallthrough` part (i.e. fallthrough is implicit). This doesn't reduce the expressive though, since you can use label-break to get arbitrary control flow or simply set a value and rely on jump threading optimisation to get the desired control flow. I can add that later if deemed necessary. r? ``@Amanieu`` cc ``@ojeda``
2024-03-06Correctly handle `cargo_target_dir`Guillaume Gomez-4/+2
2024-03-05Correctly handle "master" featureGuillaume Gomez-0/+3
2024-03-05Fix cg_gcc buildGuillaume Gomez-4/+0
2024-03-05Remove unneeded special case for rust CIGuillaume Gomez-47/+30
2024-03-05Merge commit 'b385428e3ddf330805241e7758e773f933357c4b' into ↵Guillaume Gomez-4278/+7183
subtree-update_cg_gcc_2024-03-05