Commit Graph

4119 Commits

Author SHA1 Message Date
bjorn3
91ffd74de4 Simplify GHA CI workflow 2024-04-05 13:49:29 +00:00
bjorn3
40d40fb229 Fix warning in mini_core 2024-04-05 12:25:08 +00:00
bjorn3
737421a25b Rustup to rustc 1.79.0-nightly (385fa9d84 2024-04-04) 2024-04-05 12:15:41 +00:00
bjorn3
5a9940fe3d Sync from rust 385fa9d845 2024-04-05 11:39:51 +00:00
Matthias Krüger
6728f2fef4 Rollup merge of #123419 - petrochenkov:zeroindex, r=compiler-errors
rustc_index: Add a `ZERO` constant to index types

It is commonly used.
2024-04-03 22:11:02 +02:00
bjorn3
64d6da5cda
Merge pull request #1476 from taiki-e/unchecked-shift
Fix ICE on unchecked shift
2024-04-03 19:54:56 +02:00
Vadim Petrochenkov
46fc398706 rustc_index: Add a ZERO constant to index types
It is commonly used.
2024-04-03 19:06:22 +03:00
joboet
b0710dc5f5 rename expose_addr to expose_provenance 2024-04-03 16:00:38 +02:00
Taiki Endo
4e4de3f5b7 Fix ICE on unchecked shift 2024-04-03 21:30:19 +09:00
Jacob Pratt
7a1a4565f2 Rollup merge of #122935 - RalfJung:with-exposed-provenance, r=Amanieu
rename ptr::from_exposed_addr -> ptr::with_exposed_provenance

As discussed on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/To.20expose.20or.20not.20to.20expose/near/427757066).

The old name, `from_exposed_addr`, makes little sense as it's not the address that is exposed, it's the provenance. (`ptr.expose_addr()` stays unchanged as we haven't found a better option yet. The intended interpretation is "expose the provenance and return the address".)

The new name nicely matches `ptr::without_provenance`.
2024-04-02 20:37:39 -04:00
bors
79a1bddaf3 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
bjorn3
d9f29fa018 Rustfmt all scripts 2024-03-31 09:13:11 +00:00
bjorn3
7cdec71868 Move the rustc testing section out of the readme
To make the readme a bit easier to read.
2024-03-31 09:01:37 +00:00
bjorn3
e7829154b6 Rustup to rustc 1.79.0-nightly (faae5f1ff 2024-03-29) 2024-03-30 11:02:18 +00:00
bjorn3
362caf7a70 Sync from rust faae5f1ffe 2024-03-30 10:50:14 +00:00
bors
b2f6349b49 Auto merge of #122450 - Urgau:simplify-trim-paths-feature, r=michaelwoerister
Simplify trim-paths feature by merging all debuginfo options together

This PR simplifies the trim-paths feature by merging all debuginfo options together, as described in https://github.com/rust-lang/rust/issues/111540#issuecomment-1994010274.

And also do some correctness fixes found during the review.

cc `@weihanglo`
r? `@michaelwoerister`
2024-03-29 14:00:21 +00:00
bors
e8c13080f7 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
Urgau
4d7ded634a Replace Session should_remap_filepaths with filename_display_preference 2024-03-28 18:47:26 +01:00
Urgau
6a2b2b43bd Introduce FileNameMapping::to_real_filename and use it everywhere 2024-03-28 18:47:26 +01:00
Urgau
d6a817a7d9 Make local_crate_source_file return a RealFileName
so it can be remapped (or not) by callers
2024-03-28 18:47:26 +01:00
Urgau
5de668acb0 Replace RemapFileNameExt::for_codegen with explicit calls 2024-03-28 18:47:26 +01:00
bjorn3
29b2d426b5 Merge branch 'sync_from_rust' 2024-03-28 11:45:32 +00:00
bjorn3
c5c31447a7 Merge commit '09fae60a86b848a2fc0ad219ecc4e438dc1eef86' into sync_cg_clif-2024-03-28 2024-03-28 11:43:35 +00:00
bjorn3
09fae60a86 Fix rustc test suite 2024-03-28 11:38:15 +00:00
bjorn3
ef0b3d1def Rustup to rustc 1.79.0-nightly (c9f8f3438 2024-03-27) 2024-03-28 11:17:20 +00:00
bjorn3
4f0cde1e51 Define return type for functions in debuginfo 2024-03-27 20:36:49 +00:00
bjorn3
0634aedbb7 Implement debug_type for tuples 2024-03-27 20:29:50 +00:00
bjorn3
55a2446a53 Don't panic when layout can't be computed and fix generation of array type debuginfo 2024-03-27 20:07:36 +00:00
bjorn3
fee1204ffa Stop taking FunctionCx's fn_abi field 2024-03-27 19:49:20 +00:00
bjorn3
69363cf9e7
Merge pull request #1472 from rust-lang/debuginfo_improvements2
Add debuginfo for statics
2024-03-27 19:22:09 +01:00
bjorn3
4b80941ae3 Add debuginfo for statics
Most types are still unimplemented and get a placeholder byte array
instead.
2024-03-27 16:53:57 +00:00
bjorn3
f086e7abaf Allow debuginfo to reference global variables 2024-03-27 15:01:25 +00:00
bjorn3
1f75f0fcad Move FileId caching to DebugContext::add_source_file 2024-03-27 14:14:30 +00:00
bjorn3
68b59311fa
Merge pull request #1470 from rust-lang/debuginfo_improvements
Various small debuginfo improvements
2024-03-27 15:08:07 +01:00
bjorn3
41246b2cf6 Remove fixed todos 2024-03-27 13:35:32 +00:00
bjorn3
a64387bb6b Emit DW_AT_external if applicable 2024-03-27 13:28:40 +00:00
bjorn3
98eaaeda11 Match unit names with cg_llvm 2024-03-27 12:57:24 +00:00
bjorn3
e48d7d242f Emit namespace debuginfo 2024-03-27 12:43:47 +00:00
bjorn3
c76c269aa4 Reduce debuginfo divergence between cg_llvm and cg_clif 2024-03-27 11:04:35 +00:00
bjorn3
09ec683ae7 Emit DW_AT_frame_base debuginfo attribute 2024-03-27 10:57:13 +00:00
bjorn3
cfd7325f20
Merge pull request #1469 from rust-lang/fix_some_rustc_tests
Fix a bunch of rustc tests
2024-03-26 12:19:01 +01:00
bjorn3
34d0f6a1d4 Re-enable fixed rustc test 2024-03-26 11:03:50 +00:00
bjorn3
23868af850 Correctly implement --emit 2024-03-26 10:55:46 +00:00
bjorn3
ad1886a5f0 Fix rustdoc help message when no args are passed 2024-03-26 10:27:19 +00:00
bjorn3
dc6595ddbc Implement nearbyintf32 and nearbyintf64 and remove two test ignores 2024-03-26 10:18:44 +00:00
bjorn3
60921608f7 Rustup to rustc 1.79.0-nightly (5f2c7d2bf 2024-03-25) 2024-03-26 09:56:55 +00:00
bjorn3
d183a5186f Sync from rust 5f2c7d2bfd 2024-03-26 09:50:48 +00:00
Matthias Krüger
22e4175bd6 Rollup merge of #123034 - bjorn3:test_ignores, r=compiler-errors
Add a bunch of needs-unwind annotations to tests

To filter out tests that fail with cg_clif due to missing panic=unwind support.
2024-03-25 17:05:36 +01:00
bjorn3
49777c3bfa Add needs-unwind for proc macro tests
Rustc gives a warning when compiling proc macros with panic=abort.
2024-03-25 15:02:55 +00:00
bjorn3
654ce59f70 Remove ignore for fixed rustc test 2024-03-25 14:41:19 +00:00