Commit Graph

59 Commits

Author SHA1 Message Date
Jacob Pratt
e2f5373428 Rollup merge of #159450 - amirHdev:add-codegen-test-enum-clone, r=chenyukang
Add codegen test for enum clone

Closes rust-lang/rust#69174
2026-07-28 01:38:34 -04:00
Jacob Pratt
2408dfeac2 Rollup merge of #159129 - amirHdev:add-codegen-test-signed-nonzero-matches, r=nnethercote
Add codegen test for signed nonzero matches

Closes rust-lang/rust#84311
2026-07-20 02:59:40 -04:00
Amirhossein Akhlaghpour
f849721dbd chore: add codegen test for enum clone
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
2026-07-17 18:08:12 +03:30
Jonathan Brouwer
223b78e0f0 Rollup merge of #159391 - nikic:llvm23-test-updates, r=cuviper
Update tests for LLVM 23

Fixes https://github.com/rust-lang/rust/issues/158880.
Fixes https://github.com/rust-lang/rust/issues/158572.
Fixes https://github.com/rust-lang/rust/issues/156050.

One test is disabled on LLVM 23, because it's no longer optimized as expected. Tracked in https://github.com/rust-lang/rust/issues/154141 and https://github.com/llvm/llvm-project/issues/209216.
2026-07-17 15:22:09 +02:00
Nikita Popov
d4a24cd6e1 Adjust codegen test for LLVM 23
The assume here is not really relevant to the purpose of the test,
and it's position changed in LLVM 23.
2026-07-16 16:35:50 +02:00
Amirhossein Akhlaghpour
d376c08f42 chore: add codegen test for remainder match
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
2026-07-13 20:19:43 +03:30
Jacob Pratt
27be0a26ec Rollup merge of #159069 - amirHdev:add-codegen-test-issue-91010, r=nnethercote
Add codegen test for constant returns after local use

Closes rust-lang/rust#91010
2026-07-13 05:52:58 -04:00
Amirhossein Akhlaghpour
530062b84e chore: add codegen test for trailing zeros match
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
2026-07-12 20:37:32 +03:30
Amirhossein Akhlaghpour
cf92b22d96 chore: add codegen test for signed nonzero matches
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
2026-07-11 15:05:24 +03:30
Amirhossein Akhlaghpour
08d79a6ec9 chore: add codegen test for issue 91010
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
2026-07-10 14:28:39 +03:30
Amirhossein Akhlaghpour
8bb04f6b4c chore: add codegen test for Result is_ok unwrap
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
2026-07-08 20:53:35 +03:30
Jonathan Brouwer
67b5ab7707 Rollup merge of #155722 - jchlanda:jakub/pac, r=davidtwco
Introduce aarch64-unknown-linux-pauthtest target

This target enables Pointer Authentication Code (PAC) support in Rust on AArch64
ELF-based Linux systems. It uses the `aarch64-unknown-linux-pauthtest` LLVM
target and a pointer-authentication-enabled sysroot with a custom musl as a
reference libc implementation. Dynamic linking is required, with a dynamic
linker acting as the ELF interpreter that can resolve pauth relocations and
enforce pointer authentication constraints.

### Supported features include:
* authentication of signed function pointers for extern "C" calls (corresponds
  to LLVM's `-fptrauth-calls`)
* signing of return addresses before spilling to the stack and authentication
  after restoring for non-leaf functions (corresponds to `-fptrauth-returns`)
* trapping on authentication failure when the FPAC feature is not present
  (corresponds to `-fptrauth-auth-traps`)
* signing of init/fini array entries using the LLVM-defined pointer
  authentication scheme (corresponds to `-fptrauth-init-fini` and
  `-fptrauth-init-fini-address-discrimination`)
* non-ABI-affecting indirect control-flow hardening features as implemented in
  LLVM (corresponds to `-faarch64-jump-table-hardening` and
  `-fptrauth-indirect-gotos`)
* signed ELF GOT entries (gated behind `-Z ptrauth-elf-got`, off by default)

Existing compiler support, such as enabling branch authentication instructions
(i.e.: `-Z branch-protection`) provide limited functionality, mainly signing
return addresses (`pac-ret`). The new target goes further by enabling ABI-level
pointer authentication support.

This target does not define a new ABI; it builds on the existing C/C++ language
ABI with pointer authentication support added. However, different authentication
features, encoded in the signing schema, are not ABI-compatible with one
another.

### Useful links:
* Earlier PR: https://github.com/rust-lang/rust/pull/154759
* Part of: https://github.com/rust-lang/rust/issues/148640
* Project goal: https://rust-lang.github.io/rust-project-goals/2026/aarch64_pointer_authentication_pauthtest.html
* Clang pointer authentication documentation:
  https://clang.llvm.org/docs/PointerAuthentication.html
* LLVM pointer authentication documentation:
  https://llvm.org/docs/PointerAuth.html
* PAuth ABI Extension to ELF for the AArch64 architecture:
  https://github.com/ARM-software/abi-aa/blob/main/pauthabielf64/pauthabielf64.rst

### Tier 3 check list
> - A tier 3 target must have a designated developer or developers (the "target
>   maintainers") on record to be CCed when issues arise regarding the target.
>   (The mechanism to track and CC such developers may evolve over time.)

I pledge to do my best maintaining it.

> - Targets must use naming consistent with any existing targets; for instance, a
>   target for the same CPU or OS as an existing Rust target should use the same
>   name for that CPU or OS. Targets should normally use the same names and
>   naming conventions as used elsewhere in the broader ecosystem beyond Rust
>   (such as in other toolchains), unless they have a very good reason to
>   diverge. Changing the name of a target can be highly disruptive, especially
>   once the target reaches a higher tier, so getting the name right is important
>   even for a tier 3 target.

The name chosen for the target is `aarch64-unknown-linux-pauthtest` which
mirrors the [LLVM target naming](https://github.com/llvm/llvm-project/blob/main/llvm/unittests/TargetParser/TripleTest.cpp#L1407).

>   - Target names should not introduce undue confusion or ambiguity unless
>     absolutely necessary to maintain ecosystem compatibility. For example, if
>     the name of the target makes people extremely likely to form incorrect
>     beliefs about what it targets, the name should be changed or augmented to
>     disambiguate it.

There should be no confusion, the name follows naming convention and is
descriptive.

>   - If possible, use only letters, numbers, dashes and underscores for the name.
>     Periods (`.`) are known to cause issues in Cargo.

Letters, numbers and dashes only.

> - Tier 3 targets may have unusual requirements to build or use, but must not
>   create legal issues or impose onerous legal terms for the Rust project or for
>   Rust developers or users.

The target requires system `clang` and `lld` available as well as custom libc
([musl](https://github.com/access-softek/musl) based) and sysroot, provided [through the build scripts](https://github.com/access-softek/pauth-toolchain-build-scripts/tree/master).

>   - The target must not introduce license incompatibilities.

There are no license implications.

>   - Anything added to the Rust repository must be under the standard Rust
>     license (`MIT OR Apache-2.0`).

Understood.

>   - The target must not cause the Rust tools or libraries built for any other
>     host (even when supporting cross-compilation to the target) to depend
>     on any new dependency less permissive than the Rust licensing policy. This
>     applies whether the dependency is a Rust crate that would require adding
>     new license exceptions (as specified by the `tidy` tool in the
>     rust-lang/rust repository), or whether the dependency is a native library
>     or binary. In other words, the introduction of the target must not cause a
>     user installing or running a version of Rust or the Rust tools to be
>     subject to any new license requirements.

There are no new dependencies or requirements.

>   - Compiling, linking, and emitting functional binaries, libraries, or other
>     code for the target (whether hosted on the target itself or cross-compiling
>     from another target) must not depend on proprietary (non-FOSS) libraries.
>     Host tools built for the target itself may depend on the ordinary runtime
>     libraries supplied by the platform and commonly used by other applications
>     built for the target, but those libraries must not be required for code
>     generation for the target; cross-compilation to the target must not require
>     such libraries at all. For instance, `rustc` built for the target may
>     depend on a common proprietary C runtime library or console output library,
>     but must not depend on a proprietary code generation library or code
>     optimization library. Rust's license permits such combinations, but the
>     Rust project has no interest in maintaining such combinations within the
>     scope of Rust itself, even at tier 3.

The target only relies on open source tools.

>   - "onerous" here is an intentionally subjective term. At a minimum, "onerous"
>     legal/licensing terms include but are *not* limited to: non-disclosure
>     requirements, non-compete requirements, contributor license agreements
>     (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms,
>     requirements conditional on the employer or employment of any particular
>     Rust developers, revocable terms, any requirements that create liability
>     for the Rust project or its developers or users, or any requirements that
>     adversely affect the livelihood or prospects of the Rust project or its
>     developers or users.

No such terms present.

> - Neither this policy nor any decisions made regarding targets shall create any
>   binding agreement or estoppel by any party. If any member of an approving
>   Rust team serves as one of the maintainers of a target, or has any legal or
>   employment requirement (explicit or implicit) that might affect their
>   decisions regarding a target, they must recuse themselves from any approval
>   decisions regarding the target's tier status, though they may otherwise
>   participate in discussions.

Understood.

>   - This requirement does not prevent part or all of this policy from being
>     cited in an explicit contract or work agreement (e.g. to implement or
>     maintain support for a target). This requirement exists to ensure that a
>     developer or team responsible for reviewing and approving a target does not
>     face any legal threats or obligations that would prevent them from freely
>     exercising their judgment in such approval, even if such judgment involves
>     subjective matters or goes beyond the letter of these requirements.

Understood.

> - Tier 3 targets should attempt to implement as much of the standard libraries
>   as possible and appropriate (`core` for most targets, `alloc` for targets
>   that can support dynamic memory allocation, `std` for targets with an
>   operating system or equivalent layer of system-provided functionality), but
>   may leave some code unimplemented (either unavailable or stubbed out as
>   appropriate), whether because the target makes it impossible to implement or
>   challenging to implement. The authors of pull requests are not obligated to
>   avoid calling any portions of the standard library on the basis of a tier 3
>   target not implementing those portions.

`aarch64-unknown-linux-pauthtest target` has std library support, moreover all
`library` tests pass for the target.

> - The target must provide documentation for the Rust community explaining how
>   to build for the target, using cross-compilation if possible. If the target
>   supports running binaries, or running tests (even if they do not pass), the
>   documentation must explain how to run such binaries or tests for the target,
>   using emulation if possible or dedicated hardware if necessary.

Platform support document covers building instructions.

> - Tier 3 targets must not impose burden on the authors of pull requests, or
>   other developers in the community, to maintain the target. In particular,
>   do not post comments (automated or manual) on a PR that derail or suggest a
>   block on the PR based on a tier 3 target. Do not send automated messages or
>   notifications (via any medium, including via `@`) to a PR author or others
>   involved with a PR regarding a tier 3 target, unless they have opted into
>   such messages.

Understood.

>   - Backlinks such as those generated by the issue/PR tracker when linking to
>     an issue or PR are not considered a violation of this policy, within
>     reason. However, such messages (even on a separate repository) must not
>     generate notifications to anyone involved with a PR who has not requested
>     such notifications.

Understood.

> - Patches adding or updating tier 3 targets must not break any existing tier 2
>   or tier 1 target, and must not knowingly break another tier 3 target without
>   approval of either the compiler team or the maintainers of the other tier 3
>   target.

Understood.

>   - In particular, this may come up when working on closely related targets,
>     such as variations of the same architecture with different features. Avoid
>     introducing unconditional uses of features that another variation of the
>     target may not have; use conditional compilation or runtime detection, as
>     appropriate, to let each target run code supported by that target.

Understood.

> - Tier 3 targets must be able to produce assembly using at least one of
>   rustc's supported backends from any host target. (Having support in a fork
>   of the backend is not sufficient, it must be upstream.)

It is expected that the target should be able to compile binaries on any systems
that are capable of compiling `aarch64` code.
2026-06-30 03:41:22 +02:00
Ben Kimock
96bf9d674b Revert "LLVM 23: Adapt codegen test to moved assume"
This reverts commit 4691890587.
2026-06-27 17:29:27 -04:00
Jakub Chlanda
23a7ecb97c PR feedback: Teach bootstrap 2026-06-26 13:24:12 +00:00
Jakub Chlanda
7669c44981 Teach bootstrap how to build rust_test_helpers for pauthtest
Also:
* update tests to force dynamic library when targetting pauthtest
* various test fixes
* introduce end-to-end tests for pauthtest (in run-make)
2026-06-26 13:24:12 +00:00
Tim Neumann
4691890587 LLVM 23: Adapt codegen test to moved assume 2026-06-25 11:01:49 +02:00
Augie Fackler
1f7863d3a1 tests: adapt two tests for LLVM 23 changes
LLVM 23 recently changed SimplifyCFG to avoid integer lookup tables, and
that perturbed these two tests in ways that look harmless to me.
2026-06-12 14:58:37 -04:00
DaniPopes
fd2e542110 Add regression test for issue 144329 2026-04-27 04:07:34 +02:00
Jonathan Brouwer
8beec0111d Rollup merge of #155370 - iyernaveenr:naveen_r_iyer/issue-114532-needs-test, r=Mark-Simulacrum
Add regression test for dead code elimination with drop + panic

Add a codegen test for rust-lang/rust#114532.

The bug was that dead code elimination failed when a `Drop` impl contained a `panic!` and a potentially-panicking external function was called after the value was created. This was fixed since 1.82 but no regression test was added.

The test verifies that `foo()` compiles to just a call to `unknown()` + `ret void`, with no panic or panicking call in the function body.

Closes rust-lang/rust#114532
2026-04-19 16:04:29 +02:00
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
Naveen Iyer
46f360abbd Add regression test for dead code elimination with drop + panic
Dead code elimination used to fail when a Drop impl contained a panic
and a potentially-panicking external function was called after the value
was created. This was fixed since 1.82 but no regression test was added.

The test verifies that foo() compiles to just a call to unknown() and
ret void, with no panic or panicking call in the function body.

Signed-off-by: Naveen R. Iyer <iyernaveenr@gmail.com>
2026-04-16 01:48:00 +00: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