Commit Graph

39 Commits

Author SHA1 Message Date
bors 8da2d28cbd Auto merge of #142531 - ohadravid:better-storage-calls-copy-prop, r=tmiasko,cjgillot,saethlin
Remove fewer Storage calls in CopyProp and GVN



Modify the CopyProp and GVN MIR optimization passes to remove fewer `Storage{Live,Dead}` calls, allowing for better optimizations by LLVM - see rust-lang/rust#141649.

### Details

The idea is to use a new `MaybeUninitializedLocals` analysis and remove only the storage calls of locals that are maybe-uninit when accessed in a new location.
2026-04-18 09:16:07 +00:00
Ohad Ravid 5632001f83 Improve copy_prop and GVN mir-opt passes to remove fewer storage calls 2026-04-17 16:55:43 +03:00
John Kåre Alsaker 99ed1b81d7 Make convert_while_ascii unsafe 2026-04-14 20:27:30 +02:00
Augie Fackler b7c226c0b0 tests: accept new GEP source element type 2026-03-13 10:17:20 -04:00
Josh Stone 52dfa94cdc Update the minimum external LLVM to 21 2026-03-12 16:45:42 -07:00
Jonathan Brouwer 662798eb63 Rollup merge of #153305 - TimNN:bundle-assert, r=Mark-Simulacrum
Adapt codegen test to accept operand bundles

The updated test current fails when rustc is built with HEAD LLVM: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/44013/steps/canvas?sid=019cafec-3cca-44b2-aa9f-b41c0a940e8b

Likely as a result of https://github.com/llvm/llvm-project/pull/169923

Since the new codegen merges two lines into one, I couldn't figure out a way to make the test work on both LLVM versions without introducing revisions. (Though I could instead make the test run on only LLVM 23+).

@rustbot label llvm-main
2026-03-09 11:49:24 +01:00
Tim Neumann 13ddff53be Adapt codegen test to accept operand bundles 2026-03-02 21:06:11 +01:00
Jonathan Brouwer 1654b17cd8 Rollup merge of #151780 - rwardd:ryan/fix-option-permutations, r=nikic
Updated slice tests to pass for big endian hosts for `multiple-option-or-permutations.rs`

It was discovered that the FileCheck tests when performing an `Option::or` operation on a slice was failing when tested on a big endian host.

The compiler explorer link is here outlining the codegen output differences - https://rust.godbolt.org/z/qdE7d3G4f

This MR relaxes the constraints for the `*slice_u8` variants of the test (by changing `CHECK-NEXT` to `CHECK-DAG`), whilst still maintaining the check for the necessary `or` logic.

Huge thanks to @Gelbpunkt for identifying this issue! It has been confirmed that this fix passes on a big endian target now as well.

Closes rust-lang/rust#151718
2026-03-02 20:10:33 +01:00
Alex Crichton 57d20c1d14 Revert "Simplify internals of {Rc,Arc}::default"
This reverts commit ce4c17f615.
2026-02-25 13:09:14 -08:00
Jonathan Brouwer 00d849a1b9 Rollup merge of #152591 - alexcrichton:simplify-rc-arc-default, r=joboet
Simplify internals of `{Rc,Arc}::default`

This commit simplifies the internal implementation of `Default` for these two pointer types to have the same performance characteristics as before (a side effect of changes in rust-lang/rust#131460) while avoid use of internal private APIs of Rc/Arc. To preserve the same codegen as before some non-generic functions needed to be tagged as `#[inline]` as well, but otherwise the same IR is produced before/after this change.

The motivation of this commit is I was studying up on the state of initialization of `Arc` and `Rc` and figured it'd be nicer to reduce the use of internal APIs and instead use public stable APIs where possible, even in the implementation itself.
2026-02-22 11:31:13 +01:00
dianqk 05f417cc46 Add assume to single target 2026-02-17 10:11:01 +08:00
Alex Crichton ce4c17f615 Simplify internals of {Rc,Arc}::default
This commit simplifies the internal implementation of `Default` for
these two pointer types to have the same performance characteristics as
before (a side effect of changes in 131460) while avoid use of internal
private APIs of Rc/Arc. To preserve the same codegen as before some
non-generic functions needed to be tagged as `#[inline]` as well, but
otherwise the same IR is produced before/after this change.

The motivation of this commit is I was studying up on the state of
initialization of `Arc` and `Rc` and figured it'd be nicer to reduce the
use of internal APIs and instead use public stable APIs where possible,
even in the implementation itself.
2026-02-14 10:56:42 -08:00
Ryan Ward 5265ee0637 fix: refactored to use directives instead of CHECK-DAG 2026-02-08 15:34:23 +10:30
Ryan Ward 0bf2d005fd fix: updated slice tests to pass for big endian hosts 2026-02-08 15:34:23 +10:30
Hans Wennborg 23e5b2499f Adopt matches-logical-or-141497.rs to LLVM HEAD
After http://github.com/llvm/llvm-project/pull/178977, the and + icmp
are folded to trunc.
2026-02-04 19:20:10 +01:00
Matthias Krüger b651be2191 Rollup merge of #145393 - clubby789:issue-138497, r=Mark-Simulacrum
Add codegen test for removing trailing zeroes from `NonZero`

Closes rust-lang/rust#138497
2026-01-25 07:42:56 +01:00
Jamie Hill-Daniel 76438f032a Add codegen test for issue 138497 2026-01-20 21:37:31 +00:00
Ryan Ward a2fcb0de18 fix: add CHECK directives to ret comments and be more pervasive with directive contents 2026-01-03 12:50:38 +10:30
Ryan 3df06f5083 fix: use std::num::NonZero instead of extern crate and extend information in CHECK- directives
Co-authored-by: scottmcm <scottmcm@users.noreply.github.com>
2026-01-03 10:53:54 +10:30
Ryan Ward 66c4ead02d fix: added further CHECK-SAME labels and replaced all struct input tests with NonZero<u8> input 2026-01-02 12:54:17 +10:30
Ryan bf2078bfca fix: add CHECK-SAME labels to verify generated function type for u8 and [u8; 1] cases
Co-authored-by: scottmcm <scottmcm@users.noreply.github.com>
2026-01-02 12:01:55 +10:30
Ryan Ward 80acf74fb6 test: added codegen tests for permutations of Option::or 2026-01-01 22:28:32 +10:30
Zachary S 9a8dc7e17c Replace uses of 'CHECK: br' and 'CHECK-NOT: br' with 'br {{.*}}'.
v0 mangling can produce symbols with 'br' as a substring, leading to false positives for CHECK-NOT
2025-11-21 13:04:48 -06:00
David Wood ff00110543 sess: default to v0 symbol mangling
Rust's current mangling scheme depends on compiler internals; loses
information about generic parameters (and other things) which makes for
a worse experience when using external tools that need to interact with
Rust symbol names; is inconsistent; and can contain `.` characters
which aren't universally supported. Therefore, Rust has defined its own
symbol mangling scheme which is defined in terms of the Rust language,
not the compiler implementation; encodes information about generic
parameters in a reversible way; has a consistent definition; and
generates symbols that only use the characters `A-Z`, `a-z`, `0-9`, and
`_`.

Support for the new Rust symbol mangling scheme has been added to
upstream tools that will need to interact with Rust symbols (e.g.
debuggers).

This commit changes the default symbol mangling scheme from the legacy
scheme to the new Rust mangling scheme.

Signed-off-by: David Wood <david.wood@huawei.com>
2025-11-19 11:55:09 +00:00
Matthias Krüger c772af78e9 Rollup merge of #146732 - durin42:llvm-22-less-assumes, r=nikic
tests: relax expectations after llvm change 902ddda120a5

LLVM 22 is able to drop assumes that seem to not help further optimizations, which actually seems to dramatically _help_ further optimizations in some of our small test cases.

I'm a little unclear how to fix the last failure, in `tests/codegen-llvm/issues/issue-122600-ptr-discriminant-update.rs`:

```
-; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite, inaccessiblemem: write) uwtable
+; Function Attrs: mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(argmem: readwrite, inaccessiblemem: write) uwtable
 define void ``@update(ptr`` noundef captures(none) %s) unnamed_addr #0 {
 start:
-  %_3.sroa.0.0.copyload = load i8, ptr %s, align 1
-  %0 = trunc nuw i8 %_3.sroa.0.0.copyload to i1
-  %1 = xor i1 %0, true
-  tail call void ``@llvm.assume(i1`` %1)
   store i8 1, ptr %s, align 1
   ret void
 }
```

I'm just not conversant enough in LLVM IR to follow the changes here.

``@rustbot`` label llvm-main
r? nikic
2025-09-27 21:25:57 +02:00
Augie Fackler 99456cc015 tests: use max-llvm-major-version instead of ignore-llvm-version 2025-09-26 13:32:03 -04:00
The 8472 5f0a68eb22 regression test for https://github.com/rust-lang/rust/issues/117763 2025-09-21 19:54:43 +02:00
Augie Fackler e32b975e84 tests: relax expectations after llvm change 902ddda120a5
LLVM 22 is able to drop assumes that seem to not help further
optimizations, which actually seems to dramatically _help_ further
optimizations in some of our small test cases.
2025-09-19 13:56:19 -04:00
Josh Stone 580b4891aa Update the minimum external LLVM to 20 2025-09-16 11:49:20 -07:00
Hans Wennborg 4ecca581fa Adjust issue-118306.rs test after LLVM change
This updates tests/codegen-llvm/issues/issue-118306.rs to pass also
after https://github.com/llvm/llvm-project/pull/155415
2025-09-02 12:04:04 +02:00
Jacob Pratt f0a414870a Rollup merge of #145380 - okaneco:add-codegen-tests, r=Mark-Simulacrum
Add codegen-llvm regression tests

Most of these regressions deal with elimination of panics and bounds checks that were fixed upstream by LLVM.

closes https://github.com/rust-lang/rust/issues/141497
closes https://github.com/rust-lang/rust/issues/131162
closes https://github.com/rust-lang/rust/issues/129583
closes https://github.com/rust-lang/rust/issues/110971
closes https://github.com/rust-lang/rust/issues/91109
closes https://github.com/rust-lang/rust/issues/80075
closes https://github.com/rust-lang/rust/issues/74917
closes https://github.com/rust-lang/rust/issues/71997
closes https://github.com/rust-lang/rust/issues/71257
closes https://github.com/rust-lang/rust/issues/59352
2025-08-22 22:00:50 -04:00
Karl Meakin 377a0c88a9 Consolidate panicking functions in slice/index.rs
Consolidate all the panicking functions in `slice/index.rs` to use a single
`slice_index_fail` function, similar to how it is done in `str/traits.rs`.
2025-08-21 11:07:25 +01:00
okaneco 9e28de2720 Add codegen regression tests
Most of these regressions concern elimination of panics and bounds
checks that were fixed upstream by LLVM.
2025-08-20 22:29:45 -04:00
Stuart Cook 3a694c7595 Rollup merge of #145355 - clubby789:option-match-eq, r=nikic
Add codegen test for issue 122734

Closes rust-lang/rust#122734
2025-08-18 15:31:12 +10:00
Stuart Cook 0166de2f87 Rollup merge of #145120 - maurer:llvm-time, r=nikic
llvm: Accept new LLVM lifetime format

In llvm/llvm-project#150248 LLVM removed the size parameter from the lifetime format. Tolerate not having that size parameter.
2025-08-15 16:16:37 +10:00
Jamie Hill-Daniel 9b9206980e Add test for issue 122734 2025-08-13 14:24:28 +00:00
Matthew Maurer 258915a555 llvm: Accept new LLVM lifetime format
LLVM removed the size parameter from the lifetime format.
Tolerate not having that size parameter.
2025-08-11 22:00:41 +00:00
okaneco 163594c8f8 Add regression test for saturating_sub bounds check issue
Add codegen test for issue where `valid_index.saturating_sub(X)` produced an
extra bounds check.
This was fixed by the LLVM upgrade.
2025-08-07 15:11:52 -04:00
Guillaume Gomez a27f3e3fd1 Rename tests/codegen into tests/codegen-llvm 2025-07-22 14:28:48 +02:00