rust/compiler/rustc_codegen_cranelift/src
Jacob Pratt 43d2006c25
Rollup merge of #150436 - va-list-copy, r=workingjubilee,RalfJung
`c_variadic`: impl `va_copy` and `va_end` as Rust intrinsics

tracking issue: https://github.com/rust-lang/rust/issues/44930

Implement `va_copy` as (the rust equivalent of) `memcpy`, which is the behavior of all current LLVM targets. By providing our own implementation, we can guarantee its behavior. These guarantees are important for implementing c-variadics in e.g. const-eval.

Discussed in [#t-compiler/const-eval > c-variadics in const-eval](https://rust-lang.zulipchat.com/#narrow/channel/146212-t-compiler.2Fconst-eval/topic/c-variadics.20in.20const-eval/with/565509704).

I've also updated the comment for `Drop` a bit. The background here is that the C standard requires that `va_end` is used in the same function (and really, in the same scope) as the corresponding `va_start` or `va_copy`. That is because historically `va_start` would start a scope, which `va_end` would then close. e.g.

https://softwarepreservation.computerhistory.org/c_plus_plus/cfront/release_3.0.3/source/incl-master/proto-headers/stdarg.sol

```c
#define         va_start(ap, parmN)     {\
        va_buf  _va;\
        _vastart(ap = (va_list)_va, (char *)&parmN + sizeof parmN)
#define         va_end(ap)      }
#define         va_arg(ap, mode)        *((mode *)_vaarg(ap, sizeof (mode)))
```

The C standard still has to consider such implementations, but for Rust they are irrelevant. Hence we can use `Clone` for `va_copy` and `Drop` for `va_end`.
2026-01-20 19:46:29 -05:00
..
abi rustc_target: hide TargetOptions::vendor 2025-11-09 17:43:36 -05:00
debuginfo Auto merge of #149709 - Urgau:overhaul-filenames, r=davidtwco 2025-12-13 14:32:09 +00:00
driver Merge commit '8de4afd39b' into sync_cg_clif-2025-12-18 2025-12-18 11:50:08 +00:00
intrinsics c_variadic: use Clone instead of LLVM va_copy 2026-01-20 18:38:50 +01:00
optimize Use let...else instead of match foo { ... _ => return }; and if let ... else return 2025-12-12 17:52:39 +00:00
allocator.rs Remove -Zoom=panic 2025-11-28 19:30:39 +00:00
analyze.rs rename AddressOf -> RawBorrow inside the compiler 2024-08-18 19:46:53 +02:00
base.rs Use ScalarInt from bool. 2025-12-14 17:29:59 +00:00
cast.rs Merge commit '979dcf8e2f' into sync_cg_clif-2025-05-25 2025-05-25 18:51:16 +00:00
codegen_f16_f128.rs rustc_target: hide TargetOptions::vendor 2025-11-09 17:43:36 -05:00
codegen_i128.rs Windows x86: Change i128 to return via the vector ABI 2025-01-27 12:12:59 +00:00
common.rs Merge commit 'e24f0fa3c5' into sync_cg_clif-2025-12-08 2025-12-08 16:20:48 +00:00
compiler_builtins.rs Merge commit 'a0b865dc87' into sync_cg_clif-2025-11-08 2025-11-08 14:18:53 +00:00
concurrency_limiter.rs Remove jobserver from Session 2024-12-13 10:21:22 +00:00
config.rs Merge commit 'a0b865dc87' into sync_cg_clif-2025-11-08 2025-11-08 14:18:53 +00:00
constant.rs Use ScalarInt from bool. 2025-12-14 17:29:59 +00:00
discriminant.rs Change tag_field to FieldIdx in Variants::Multiple 2025-06-03 23:42:21 -07:00
global_asm.rs Finish transition from semitransparent to semiopaque for rustc_macro_transparency 2026-01-08 19:14:45 +01:00
inline_asm.rs simplify how inline asm handles MaybeUninit 2025-12-13 15:50:02 +01:00
lib.rs Remove all allows for diagnostic_outside_of_impl and untranslatable_diagnostic throughout the codebase 2026-01-19 17:39:49 +01:00
linkage.rs Port the #[linkage] attribute to the new attribute system 2025-08-13 21:01:37 +02:00
main_shim.rs Merge commit 'a0b865dc87' into sync_cg_clif-2025-11-08 2025-11-08 14:18:53 +00:00
num.rs Replace some Option<Span> with Span and use DUMMY_SP instead of None 2025-06-05 14:14:59 +00:00
pointer.rs Merge commit '1fa693ca44' into sync_cg_clif-2024-11-09 2024-11-09 13:48:06 +00:00
pretty_clif.rs layout: Store inverse memory index in FieldsShape::Arbitrary 2025-12-18 22:25:34 +01:00
toolchain.rs Merge commit 'e9d1a0a7b0' into sync_cg_clif-2022-08-24 2022-08-24 18:40:58 +02:00
unsize.rs Merge commit 'a0b865dc87' into sync_cg_clif-2025-11-08 2025-11-08 14:18:53 +00:00
unwind_module.rs Merge commit '979dcf8e2f' into sync_cg_clif-2025-05-25 2025-05-25 18:51:16 +00:00
value_and_place.rs Merge commit 'a0b865dc87' into sync_cg_clif-2025-11-08 2025-11-08 14:18:53 +00:00
vtable.rs Merge commit 'a0b865dc87' into sync_cg_clif-2025-11-08 2025-11-08 14:18:53 +00:00