Conversation
This moves all LLVM intrinsic handling out of the regular call path for cg_gcc and makes it easier to hook into this code for future cg_llvm changes.
…acro_transparency`
It's described as a "backwards compatibility hack to keep the diff small". Removing it requires only a modest amount of churn, and the resulting code is clearer without the invisible derefs.
…ics-generation Simplify intrinsics generation
Regenerate intrinsics
Move LTO to OngoingCodegen::join This will make it easier to in the future move all this code to link_binary. Follow up to rust-lang#147810 Part of rust-lang/compiler-team#908
This is the conceptual opposite of the rust-cold calling convention and
is particularly useful in combination with the new `explicit_tail_calls`
feature.
For relatively tight loops implemented with tail calling (`become`) each
of the function with the regular calling convention is still responsible
for restoring the initial value of the preserved registers. So it is not
unusual to end up with a situation where each step in the tail call loop
is spilling and reloading registers, along the lines of:
foo:
push r12
; do things
pop r12
jmp next_step
This adds up quickly, especially when most of the clobberable registers
are already used to pass arguments or other uses.
I was thinking of making the name of this ABI a little less LLVM-derived
and more like a conceptual inverse of `rust-cold`, but could not come
with a great name (`rust-cold` is itself not a great name: cold in what
context? from which perspective? is it supposed to mean that the
function is rarely called?)
Fix segfault related to __builtin_unreachable with inline asm
…bilee
add `simd_splat` intrinsic
Add `simd_splat` which lowers to the LLVM canonical splat sequence.
```llvm
insertelement <N x elem> poison, elem %x, i32 0
shufflevector <N x elem> v0, <N x elem> poison, <N x i32> zeroinitializer
```
Right now we try to fake it using one of
```rust
fn splat(x: u32) -> u32x8 {
u32x8::from_array([x; 8])
}
```
or (in `stdarch`)
```rust
fn splat(value: $elem_type) -> $name {
#[derive(Copy, Clone)]
#[repr(simd)]
struct JustOne([$elem_type; 1]);
let one = JustOne([value]);
// SAFETY: 0 is always in-bounds because we're shuffling
// a simd type with exactly one element.
unsafe { simd_shuffle!(one, one, [0; $len]) }
}
```
Both of these can confuse the LLVM optimizer, producing sub-par code. Some examples:
- rust-lang#60637
- rust-lang#137407
- rust-lang#122623
- rust-lang#97804
---
As far as I can tell there is no way to provide a fallback implementation for this intrinsic, because there is no `const` way of evaluating the number of elements (there might be issues beyond that, too). So, I added implementations for all 4 backends.
Both GCC and const-eval appear to have some issues with simd vectors containing pointers. I have a workaround for GCC, but haven't yet been able to make const-eval work. See the comments below.
Currently this just adds the intrinsic, it does not actually use it anywhere yet.
…ochenkov
abi: add a rust-preserve-none calling convention
This is the conceptual opposite of the rust-cold calling convention and is particularly useful in combination with the new `explicit_tail_calls` feature.
For relatively tight loops implemented with tail calling (`become`) each of the function with the regular calling convention is still responsible for restoring the initial value of the preserved registers. So it is not unusual to end up with a situation where each step in the tail call loop is spilling and reloading registers, along the lines of:
foo:
push r12
; do things
pop r12
jmp next_step
This adds up quickly, especially when most of the clobberable registers are already used to pass arguments or other uses.
I was thinking of making the name of this ABI a little less LLVM-derived and more like a conceptual inverse of `rust-cold`, but could not come with a great name (`rust-cold` is itself not a great name: cold in what context? from which perspective? is it supposed to mean that the function is rarely called?)
This is necessary to support serializing the CodegenContext to a .rlink file in the future for moving LTO to the -Zlink-only step.
…1_28 Sync from rust 2026/01/28
- Readme.md: add missing "you" ("If don't" → "If you don't")
- Readme.md: fix wrong preposition ("without this backend" → "with this backend")
- Readme.md: fix double space
- doc/errors.md: fix transposed letters ("libgccijt" → "libgccjit")
- doc/debugging.md: remove extra word ("Run do the command" → "Run the command")
- doc/debugging.md: fix past participle ("cannot be ran" → "cannot be run")
- doc/tips.md: add missing verb ("won't a chance" → "won't have a chance")
- doc/gimple.md: fix preposition ("interested into" → "interested in")
Fix typos across documentation
…=wesleywiser Don't compute FnAbi for LLVM intrinsics in backends ~~This removes support for `extern "unadjusted"` for anything other than LLVM intrinsics. It only makes sense in the context of calling LLVM intrinsics anyway as it exposes the way the LLVM backend internally represents types. Perhaps it should be renamed to `extern "llvm-intrinsic"`?~~ Follow up to rust-lang#148533
Remove tm_factory field from CodegenContext This is necessary to support serializing the `CodegenContext` to a `.rlink` file in the future for moving LTO to the `-Zlink-only` step. Follow up to rust-lang#149209 Part of rust-lang/compiler-team#908
…2_12 Sync from rust 2026/02/12
…update_cg_gcc_2026-02-13
|
Some changes occurred in compiler/rustc_codegen_gcc cc @antoyo |
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
|
||
| fn run_and_optimize_fat_lto( | ||
| cgcx: &CodegenContext, | ||
| prof: &SelfProfilerRef, |
There was a problem hiding this comment.
What could have caused this?
Guillaume wasn't on the last commit?
There was a problem hiding this comment.
Maybe there was a conflict that got resolved wrongly? The cgcx: &CodegenContext, was updated in rust-lang/rustc_codegen_gcc#851 following changes in this repo. And unless you immediately sync back changes after a push to the main repo, git-subtree tends to produce conflicts out of thin air.
There was a problem hiding this comment.
The
cgcx: &CodegenContext,was updated in rust-lang/rustc_codegen_gcc#851 following changes in this repo.
Are you sure?
I don't see the prof parameter here.
There was a problem hiding this comment.
First the cgcx parameter got updated, which then got synced in rust-lang/rustc_codegen_gcc#851 and then the prof parameter got added, but after that sync. So the cg_gcc repo doesn't have it while the rust repo does. At the same time, both the cg_gcc repo and the rust repo contain changes to these lines, which may have caused a conflict.
There was a problem hiding this comment.
So, should we done another sync tomorrow and then make another sync PR here?
There was a problem hiding this comment.
That or redo the merge and properly resolve the conflicts if it was indeed an improperly resolved conflict.
r? ghost