Commit Graph

110 Commits

Author SHA1 Message Date
Karan Janthe 664e83b3e7 added typetree support for memcpy 2025-09-19 04:02:20 +00:00
Trevor Gross 6fa6a854cd Rollup merge of #144192 - RalfJung:atomicrmw-ptr, r=nikic
atomicrmw on pointers: move integer-pointer cast hacks into backend

Conceptually, we want to have atomic operations on pointers of the form `fn atomic_add(ptr: *mut T, offset: usize, ...)`. However, LLVM does not directly support such operations (https://github.com/llvm/llvm-project/issues/120837), so we have to cast the `offset` to a pointer somewhere.

This PR moves that hack into the LLVM backend, so that the standard library, intrinsic, and Miri all work with the conceptual operation we actually want. Hopefully, one day LLVM will gain a way to represent these operations without integer-pointer casts, and then the hack will disappear entirely.

Cc ```@nikic``` -- this is the best we can do right now, right?
Fixes https://github.com/rust-lang/rust/issues/134617
2025-08-08 14:22:44 -05:00
Guillaume Gomez 21bd67796e Merge commit '482e8540a1b757ed7bccc2041c5400f051fdb01e' into subtree-update_cg_gcc_2025-08-04 2025-08-04 10:49:43 +02:00
Joel Wejdenstål a448837045 Implement support for explicit tail calls in the MIR block builders and the LLVM codegen backend. 2025-07-26 01:02:29 +02:00
Ralf Jung de1b999ff6 atomicrmw on pointers: move integer-pointer cast hacks into backend 2025-07-23 08:32:55 +02:00
Guillaume Gomez 66017df336 Merge commit 'f682d09eefc6700b9e5851ef193847959acf4fac' into subtree-update_cg_gcc_2025-07-18 2025-07-18 18:31:20 +02:00
mejrs 49421d1fa3 Remove support for dynamic allocas 2025-07-07 23:04:06 +02:00
Guillaume Gomez 666934ac54 Merge commit '4b5c44b14166083eef8d71f15f5ea1f53fc976a0' into subtree-update_cg_gcc_2025-06-30 2025-06-30 16:12:42 +02:00
Guillaume Gomez 3dcbc1e5bc Remove () returned value 2025-06-29 00:20:15 +02:00
Guillaume Gomez a420d39afb Fix signature of filter_landing_pad 2025-06-29 00:00:58 +02:00
Guillaume Gomez 13d0ef30c9 Remove unwanted semi-colon in rustc_codegen_gcc 2025-06-28 23:50:00 +02:00
Guillaume Gomez f8491b11f3 Merge commit 'b7091eca6d8eb0fe88b58cc9a7aec405d8de5b85' into subtree-update_cg_gcc_2025-06-28 2025-06-28 23:37:08 +02:00
Mark Rousskov a46ef2d01e Remove dead instructions in terminate blocks 2025-06-22 11:38:47 -04:00
Guillaume Gomez c48d8d4d80 Merge commit 'fda0bb9588912a3e0606e880ca9f6e913cf8a5a4' into subtree-update_cg_gcc_2025-06-18 2025-06-18 15:11:44 +02:00
León Orell Valerian Liehr d6dc9656ea Rollup merge of #133952 - bjorn3:remove_wasm_legacy_abi, r=alexcrichton
Remove wasm legacy abi

Closes https://github.com/rust-lang/rust/issues/122532
Closes https://github.com/rust-lang/rust/issues/138762
Fixes https://github.com/rust-lang/rust/issues/71871
https://github.com/rust-lang/rust/issues/88152
Fixes https://github.com/rust-lang/rust/issues/115666
Fixes https://github.com/rust-lang/rust/issues/129486
2025-06-15 23:51:53 +02:00
bjorn3 3e944fa391 Remove all support for wasm's legacy ABI 2025-06-14 09:57:06 +00:00
sayantn d56fcd968d Simplify implementation of Rust intrinsics by using type parameters in the cache 2025-06-12 00:32:42 +05:30
Ralf Jung a387c86a92 get rid of rustc_codegen_ssa::common::AtomicOrdering 2025-05-28 22:57:55 +02:00
Guillaume Gomez 1c4ab86955 Merge commit '6ba33f5e1189a5ae58fb96ce3546e76b13d090f5' into subtree-update_cg_gcc_2025-05-14 2025-05-14 13:51:02 +02:00
Ralf Jung 79dfd0a472 remove 'unordered' atomic intrinsics 2025-05-09 17:39:52 +02:00
Matthias Krüger 555df301f8 Rollup merge of #134232 - bjorn3:naked_asm_improvements, r=wesleywiser
Share the naked asm impl between cg_ssa and cg_clif

This was introduced in https://github.com/rust-lang/rust/pull/128004.
2025-04-30 17:27:57 +02:00
Guillaume Gomez e4ea67b3d7 Merge commit 'db1a31c243a649e1fe20f5466ba181da5be35c14' into subtree-update_cg_gcc_2025-04-18 2025-04-18 21:20:11 +02:00
bjorn3 421f22e8bf Pass &mut self to codegen_global_asm 2025-04-14 09:38:04 +00:00
Thalia Archibald 38fad984c6 compiler: Use size_of from the prelude instead of imported
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the
prelude instead of importing or qualifying them.

These functions were added to all preludes in Rust 1.80.
2025-03-07 13:37:04 -08:00
Scott McMurray 6f9cfd694d Rework OperandRef::extract_field to stop calling to_immediate_scalar on things which are already immediates
That means it stops trying to truncate things that are already `i1`s.
2025-02-19 12:03:40 -08:00
Scott McMurray 511bf307f0 Emit trunc nuw for unchecked shifts and to_immediate_scalar
- For shifts this shrinks the IR by no longer needing an `assume` while still providing the UB information
- Having this on the `i8`→`i1` truncations will hopefully help with some places that have to load `i8`s or pass those in LLVM structs without range information
2025-02-19 11:36:52 -08:00
Scott McMurray 9ad6839f7a Set both nuw and nsw in slice size calculation
There's an old note in the code to do this, and now that LLVM-C has an API for it, we might as well.
2025-02-13 21:26:48 -08:00
bjorn3 1fcae03369 Rustfmt 2025-02-08 22:12:13 +00:00
Jubilee Young e42cb3bedc cg_gcc: Directly use rustc_abi instead of reexports 2025-02-04 22:31:56 -08:00
Antoni Boucher 06f0a9bc78 Merge commit '59a81c2ca1edc88ad3ac4b27a8e03977ffb8e73a' into subtree-update_cg_gcc_2025_01_12 2025-01-13 10:53:58 -05:00
lcnr 9cba14b95b use TypingEnv when no infcx is available
the behavior of the type system not only depends on the current
assumptions, but also the currentnphase of the compiler. This is
mostly necessary as we need to decide whether and how to reveal
opaque types. We track this via the `TypingMode`.
2024-11-18 10:38:56 +01:00
Jubilee Young 0349209901 cg_gcc: rustc_abi::Abi => BackendRepr 2024-10-29 15:01:01 -07:00
Zalathar 8f07514520 coverage: SSA doesn't need to know about instrprof_increment 2024-10-25 14:24:05 +11:00
Andrew Zhogin b3ae64d24f rust_for_linux: -Zregparm=<N> commandline flag for X86 (#116972) 2024-10-18 00:29:31 +07:00
Jubilee Young d92aee556d cg_gcc: Factor out rustc_target::abi 2024-10-08 18:24:56 -07:00
Guillaume Gomez 325b70890a Merge commit '3187d32079b817522cc17413ec9185b130daf693' into subtree-update 2024-09-27 22:00:17 +02:00
bors 4cbfcf1b7f Auto merge of #130389 - Luv-Ray:LLVMMDNodeInContext2, r=nikic
llvm: replace some deprecated functions

`LLVMMDStringInContext` and `LLVMMDNodeInContext` are deprecated, replace them with `LLVMMDStringInContext2` and `LLVMMDNodeInContext2`.
Also replace `Value` with `Metadata` in some function signatures for better consistency.
2024-09-24 12:07:48 +00:00
Michael Goulet c682aa162b Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
Luv-Ray b7c5656713 replace some deprecated functions 2024-09-19 09:39:28 +08:00
Nicholas Nethercote acb832d640 Use associative type defaults in {Layout,FnAbi}OfHelpers.
This avoids some repetitive boilerplate code.
2024-09-17 10:25:06 +10:00
Nicholas Nethercote a8d22eb39e Rename supertraits of CodegenMethods.
Supertraits of `BuilderMethods` are all called `XyzBuilderMethods`.
Supertraits of `CodegenMethods` are all called `XyzMethods`. This commit
changes the latter to `XyzCodegenMethods`, for consistency.
2024-09-17 10:24:43 +10:00
Nicholas Nethercote 5f98943b5a Merge HasCodegen into BuilderMethods.
It has `Backend` and `Deref` boudns, plus an associated type
`CodegenCx`, and it has a single use. This commit "inlines" it into
`BuilderMethods`, which makes the complicated backend trait situation a
little simpler.
2024-09-17 10:24:43 +10:00
Ralf Jung 60ee1b7ac6 simd_shuffle: require index argument to be a vector 2024-09-14 14:43:24 +02:00
Ralf Jung daedbd4d7a make the GCC backend compatible with vector shuffle indices 2024-08-13 07:51:28 +02:00
Ralf Jung 28e0907111 nontemporal_store: make sure that the intrinsic is truly just a hint 2024-08-05 10:57:14 +02:00
Nicholas Nethercote 84ac80f192 Reformat use declarations.
The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
2024-07-29 08:26:52 +10:00
Guillaume Gomez 213782dd71 Format cg_gcc with same formatting parameters 2024-07-17 20:22:07 +02:00
Guillaume Gomez 541b32c8ab Update Cargo.lock and remove duplicated impl 2024-07-10 13:02:26 +02:00
Guillaume Gomez 7cbe50e209 Merge commit '98ed962c7d3eebe12c97588e61245273d265e72f' into master 2024-07-10 12:44:23 +02:00
Ralf Jung 95582e6fcb codegen: memmove/memset cannot be non-temporal 2024-05-09 18:59:00 +02:00