Commit Graph

1417 Commits

Author SHA1 Message Date
Michael Baikov
040afd36f3 Save/restore more items in cache with incremental compilation 2024-04-06 10:59:24 -04:00
Guillaume Gomez
5eb8d854d1 Rename cargo.rs into rust_tools.rs to prepare the addition of the rustc command 2024-04-05 17:18:55 +02:00
Guillaume Gomez
f7a6ac1c9a Rollup merge of #122334 - GuillaumeGomez:vendor-cg_gcc, r=Mark-Simulacrum
Vendor rustc_codegen_gcc

I used https://github.com/rust-lang/rust/pull/115274 as base for this update.

r? `@bjorn3`
2024-04-05 16:38:49 +02:00
bors
27ba1bad27 Auto merge of #118310 - scottmcm:three-way-compare, r=davidtwco
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 8811efa88b (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-04-02 19:21:44 +00:00
antoyo
75f0ab5c55
Merge pull request #482 from antoyo/master
Sync from fork
2024-03-30 09:51:27 -04:00
antoyo
287894f374
Merge pull request #14 from antoyo/fix/vm-link-and-stdarch-tests
Fix vm link and stdarch tests
2024-03-30 09:05:45 -04:00
Antoni Boucher
c7ac792687 Add newlines 2024-03-30 08:18:56 -04:00
Antoni Boucher
92be47bef5 Add back y.sh to run stdarch tests 2024-03-30 08:16:03 -04:00
Antoni Boucher
03f299bce0 Fix VM artifact link 2024-03-30 08:14:53 -04:00
Aria Beingessner
cc98f86d4d stabilize ptr.is_aligned, move ptr.is_aligned_to to a new feature gate
This is an alternative to #121920
2024-03-29 19:59:46 -04:00
bors
211b585c60 Auto merge of #122671 - Mark-Simulacrum:const-panic-msg, r=Nilstrieb
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-29 00:24:01 +00:00
Robert Zakrzewski
111b3395a8
Execute tests using a target defined as a JSON spec (#12) 2024-03-27 17:37:19 -04:00
Shashank Trivedi
2a88451d6b
run-make tests initialized (#7) 2024-03-25 11:39:26 -04:00
antoyo
fda1ffd38f
Merge pull request #8 from zedar/I60_asm_conversion_from_register_to_gcc
Add missing mappings from register classes to dummy output types
2024-03-24 14:39:10 -04:00
Robert Zakrzewski
94ca8283af add missing mappings from register classes to dummy output types
fix formatting

Replace LLVM with GCC
2024-03-24 17:22:40 +01:00
Matthias Krüger
1ee4ae9eb2 Rollup merge of #122937 - Zalathar:unbox, r=oli-obk
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-24 17:08:16 +01:00
Scott McMurray
1a05106f94 Add+Use mir::BinOp::Cmp 2024-03-23 23:23:41 -07:00
antoyo
51eae7e6e8
Merge pull request #5 from mubarak23/remove-pass-test
Remove pass test
2024-03-23 17:45:16 -04:00
mubarak23
a67cd0c4fd add fn-arg-incomplete-pattern-drop-order.rs to the list 2024-03-23 22:18:22 +01:00
Matthew Maurer
abbe1ba6f2 CFI: Use Instance at callsites
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-23 18:30:39 +00:00
mubarak23
0319a80c5b remove more test that have passed 2024-03-23 19:21:45 +01:00
mubarak23
56eab3c484 remove trailing space 2024-03-23 18:09:18 +01:00
mubarak23
9c81910732 fix rebase 2024-03-23 13:27:33 +01:00
Zalathar
95c7fde6b1 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.
2024-03-23 22:05:11 +11:00
bors
a951158565 Auto merge of #119552 - krtab:dead_code_priv_mod_pub_field, r=cjgillot,saethlin
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-23 00:37:05 +00:00
antoyo
eea2f89c80
Merge pull request #2 from GuillaumeGomez/rm-build_sysroot-folder
Remove `build_sysroot` folder
2024-03-22 16:37:06 -04:00
Guillaume Gomez
da070d3569 Clean up y.sh path in CI 2024-03-22 20:37:55 +01:00
Shashank Trivedi
f16a006c23
CI cargo test added (#6) 2024-03-22 15:32:34 -04:00
Guillaume Gomez
7ccd8ce693 Add fmt check on build_system 2024-03-22 20:19:20 +01:00
Guillaume Gomez
52f6d5d589 Run test commands in the provided order 2024-03-22 20:19:20 +01:00
Guillaume Gomez
cde105a651 Move build_sysroot folder into build_system 2024-03-22 20:19:20 +01:00
Guillaume Gomez
ab1ea400a8 Format code 2024-03-22 20:19:20 +01:00
Michael Goulet
83eaede000 Make RawPtr take Ty and Mutbl separately 2024-03-22 11:13:29 -04:00
Mubarak Muhammad Aminu
906a2ab5b3
Update tests/failing-ui-tests.txt
Co-authored-by: antoyo <antoyo@users.noreply.github.com>
2024-03-22 15:51:48 +01:00
Mark Rousskov
c8cb091e1e 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 binary.
2024-03-22 09:55:50 -04:00
mubarak23
67c6c7e00d add two fail test back to the list 2024-03-22 12:29:56 +01:00
mubarak23
486f6b7300 remove lto-abort.rs since it has passed 2024-03-21 17:04:03 +01:00
mubarak23
193d165e22 add back lto-abort.rs to the list 2024-03-21 16:47:20 +01:00
mubarak23
3cb807b6d3 remove more pass test from the lists 2024-03-21 16:19:49 +01:00
mubarak23
6a2f725a45 remove pass test 2024-03-21 16:00:30 +01:00
Guillaume Gomez
9b17b3d184 Simplify directory creation 2024-03-20 15:48:59 +01:00
Guillaume Gomez
51d27a63b8 Move cleanup of sysroot build into its own function 2024-03-20 15:16:52 +01:00
antoyo
17abfa7041
Merge pull request #1 from mubarak23/remove-debug-info
remove debug info from emitting
2024-03-19 09:27:02 -04:00
mubarak23
09dbab8fab change the debug option from true to limited 2024-03-19 13:49:07 +01:00
mubarak23
4ef3bac2a6 remove debug info from emitting 2024-03-19 08:54:11 +01:00
bors
678e62405f Auto merge of #122055 - compiler-errors:stabilize-atb, r=oli-obk
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-19 00:04:09 +00:00
Erik Desjardins
ff2b405a3c revert changes and just delete the fixme
Avoiding the naming didn't have any meaningful perf impact.
2024-03-16 11:11:53 -04:00
antoyo
7ff5d39980
Merge pull request #469 from tempdragon/master
Clippy related fixes
2024-03-16 10:34:22 -04:00
tempdragon
0a493514d7 fix(lifetime): Add lifetimes back. 2024-03-16 21:30:04 +08:00
tempdragon
3b01fba0f5 fix(intrinsic/mod.rs): Update comments 2024-03-16 21:16:41 +08:00