Skip to content

Subtree update GCC backend #140015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 123 commits into from
Apr 19, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
60ee6fb
Update tests.
m-ou-se Oct 31, 2024
0f89f3f
Use a C-safe return type for `__rust_[ui]128_*` overflowing intrinsics
tgross35 Dec 15, 2024
daeeffa
Rollup merge of #132397 - m-ou-se:warn-missing-abi, r=Nadrieril
jhpratt Jan 15, 2025
cdf26a1
Rollup merge of #134338 - tgross35:overflowing-c-safe-ret, r=bjorn3,a…
jhpratt Jan 15, 2025
4600047
When LLVM's location discriminator value limit is exceeded, emit loca…
khuey Jan 17, 2025
49e047f
Treat undef bytes as equal to any other byte
oli-obk Jan 8, 2025
301d247
remove support for the #[start] attribute
RalfJung Dec 14, 2024
c482251
Auto merge of #134299 - RalfJung:remove-start, r=compiler-errors
bors Jan 21, 2025
0692ca3
Make CodegenCx and Builder generic
ZuseZ4 Jan 24, 2025
d6d7c15
Merge commit '9f33f846ddc06afd7ffd839ee4f18babac3f3204'
GuillaumeGomez Jan 24, 2025
4fec62a
Rollup merge of #135581 - EnzymeAD:refactor-codgencx, r=oli-obk
matthiaskrgr Jan 24, 2025
24ce0a2
Stabilize `const_black_box`
tgross35 Jan 12, 2025
06f8ed1
Auto merge of #136024 - GuillaumeGomez:cg_gcc-subtree, r=GuillaumeGomez
bors Jan 27, 2025
bc6b9bf
Add CI success job
Kobzol Jan 27, 2025
600999a
ABI-required target features: warn when they are missing in base CPU …
RalfJung Jan 27, 2025
90a6f2b
Do not treat vtable supertraits as distinct when bound with different…
compiler-errors Jan 10, 2025
12feb0e
Use ExistentialTraitRef throughout codegen
compiler-errors Jan 10, 2025
a05dca8
Rollup merge of #135414 - tgross35:stabilize-const_black_box, r=dtolnay
jhpratt Jan 31, 2025
afe0843
Auto merge of #136331 - jhpratt:rollup-curo1f4, r=jhpratt
bors Jan 31, 2025
3e62ac7
Merge pull request #614 from Kobzol/ci-success
antoyo Jan 31, 2025
adee084
Add success job for all CI workflows
antoyo Feb 1, 2025
b825dbc
Merge pull request #616 from rust-lang/success-job
antoyo Feb 1, 2025
ff2cd0f
Remove duplicated CI triggers
Kobzol Feb 1, 2025
befc31c
Move back to a success job so because the required checks only work w…
antoyo Feb 1, 2025
1a25284
Merge pull request #619 from Kobzol/ci-pr
antoyo Feb 1, 2025
2e0595b
Merge pull request #618 from rust-lang/success-job
antoyo Feb 1, 2025
ad2be68
Make globals always have 2+ chars as suffix
fluxchief Jan 27, 2025
5d12c54
Add M68000 entry to arch_to_gcc
fluxchief Jan 27, 2025
efb5185
Merge pull request #613 from fluxchief/68000
antoyo Feb 2, 2025
e0d8fb9
tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc`
safinaskar Feb 3, 2025
c325b82
Merge pull request #612 from fluxchief/master
antoyo Feb 3, 2025
4c932ff
Update repositories URL for repositories moved to `rust-lang` organiz…
GuillaumeGomez Jan 25, 2025
f0c0370
Merge pull request #610 from GuillaumeGomez/update-urls
antoyo Feb 3, 2025
beb24b3
intrinsics: unify rint, roundeven, nearbyint in a single round_ties_e…
RalfJung Feb 4, 2025
819ab9b
cg_gcc: Directly use rustc_abi instead of reexports
workingjubilee Nov 3, 2024
2214ba9
Run the CI on push on the master branch
antoyo Feb 5, 2025
4380568
Merge pull request #620 from rust-lang/ci-master-branch
antoyo Feb 5, 2025
db4b00f
Auto merge of #136471 - safinaskar:parallel, r=SparrowLii
bors Feb 6, 2025
09d9076
fix backslashes in path used for `asm_tests`
folkertdev Feb 7, 2025
21b60aa
Remove Linkage::Private
bjorn3 Feb 7, 2025
a90648d
Remove Linkage::Appending
bjorn3 Feb 7, 2025
f5597ff
Merge pull request #624 from folkertdev/run-asm-tests
antoyo Feb 7, 2025
83f7576
compiler: remove reexports from rustc_target::callconv
workingjubilee Feb 5, 2025
180f350
Rustfmt
bjorn3 Feb 8, 2025
01f1025
Rollup merge of #136706 - workingjubilee:finish-up-rustc-abi-updates,…
workingjubilee Feb 9, 2025
5bf05c1
Auto merge of #136751 - bjorn3:update_rustfmt, r=Mark-Simulacrum
bors Feb 9, 2025
cb499a2
remove some intrinsics (#625)
c8ef Feb 10, 2025
65da92e
cg_gcc: stop caring about compiling for unknown targets
workingjubilee Feb 10, 2025
d7f2227
compiler/rustc_codegen_gcc/src/back/lto.rs: delete "unsafe impl Sync/…
safinaskar Feb 11, 2025
c817210
handle NaN in unordered comparisons
folkertdev Feb 12, 2025
7f05920
Merge pull request #627 from folkertdev/fix-unordered-compare
antoyo Feb 12, 2025
4f59a68
Support sysv64 and ms ABIs
antoyo Feb 13, 2025
b08a0c6
Merge pull request #629 from rust-lang/feature/non-default-abis
antoyo Feb 13, 2025
feb78f9
Implement and use BikeshedGuaranteedNoDrop for union/unsafe field val…
compiler-errors Feb 6, 2025
853ae3d
Rollup merge of #136858 - safinaskar:parallel-cleanup-2025-02-11-07-5…
jhpratt Feb 13, 2025
3ecc012
fix clobbered or lateout registers overlapping with input registers
folkertdev Feb 12, 2025
1f98329
Merge pull request #628 from folkertdev/clobber-input-registers
antoyo Feb 13, 2025
fd526a2
Make `-O` mean `-C opt-level=3`
clubby789 Jan 13, 2025
5e0c773
Set both `nuw` and `nsw` in slice size calculation
scottmcm Feb 5, 2025
5e0f1f6
Auto merge of #136575 - scottmcm:nsuw-math, r=nikic
bors Feb 14, 2025
53aa977
refactor and support reg_byte registers
folkertdev Feb 13, 2025
fcac229
Merge pull request #630 from folkertdev/x86-register-classes
antoyo Feb 14, 2025
51911a7
Emit `trunc nuw` for unchecked shifts and `to_immediate_scalar`
scottmcm Feb 15, 2025
9ebb68d
Rework `OperandRef::extract_field` to stop calling `to_immediate_scal…
scottmcm Feb 16, 2025
be63572
Remove `BackendRepr::Uninhabited`, replaced with an `uninhabited: boo…
zachs18 Jan 26, 2025
aa038c2
Add `new_regular` and `new_allocator` to `ModuleCodegen`
dianqk Feb 6, 2025
9b8701d
Save pre-link bitcode to `ModuleCodegen`
dianqk Feb 6, 2025
a9e8cfe
Rollup merge of #136543 - RalfJung:round-ties-even, r=tgross35
tgross35 Feb 23, 2025
15f0dca
remove support for rustc_intrinsic_must_be_overridden from the compiler
RalfJung Feb 23, 2025
e92466e
Remove an unnecessary lifetime
oli-obk Feb 24, 2025
71c189a
Generalize BaseTypeCodegenMethods
oli-obk Feb 24, 2025
334eb82
Remove an unused lifetime param
oli-obk Feb 24, 2025
7848145
remove `simd_fpow` and `simd_fpowi`
folkertdev Feb 25, 2025
b627900
Rollup merge of #137595 - folkertdev:remove-simd-pow-powi, r=RalfJung
fmease Feb 25, 2025
7721431
Stop using `hash_raw_entry` in `CodegenCx::const_str`
cuviper Feb 27, 2025
975dee2
rename BackendRepr::Vector → SimdVector
RalfJung Feb 28, 2025
24b202f
Auto merge of #133250 - DianQK:embed-bitcode-pgo, r=nikic
bors Mar 1, 2025
d344960
Rollup merge of #137804 - RalfJung:backend-repr-simd-vector, r=workin…
matthiaskrgr Mar 1, 2025
c25f12a
Revert "Auto merge of #135335 - oli-obk:push-zxwssomxxtnq, r=saethlin"
compiler-errors Mar 2, 2025
fe9feb3
Rollup merge of #137741 - cuviper:const_str-raw_entry, r=Mark-Simulacrum
matthiaskrgr Mar 3, 2025
273fe4a
Rollup merge of #137894 - compiler-errors:no-scalar-pair-opt, r=oli-obk
matthiaskrgr Mar 3, 2025
ab17806
Auto merge of #137959 - matthiaskrgr:rollup-62vjvwr, r=matthiaskrgr
bors Mar 4, 2025
ae07d7d
Simplify `implied_target_features`.
nnethercote Feb 25, 2025
b2b94f4
Change signature of `target_features_cfg`.
nnethercote Feb 25, 2025
24bf404
Rollup merge of #137549 - oli-obk:llvm-ffi, r=davidtwco
matthiaskrgr Mar 7, 2025
70b5888
compiler: Use size_of from the prelude instead of imported
thaliaarchi Mar 5, 2025
572da5c
cleaned up tests by bringing objects under `mini_core` into scope
madhav-madhusoodanan Mar 8, 2025
499de70
Merge pull request #639 from madhav-madhusoodanan/test_update_mini_core
antoyo Mar 8, 2025
454b083
Rollup merge of #138040 - thaliaarchi:use-prelude-size-of.compiler, r…
matthiaskrgr Mar 9, 2025
b802554
Auto merge of #137586 - nnethercote:SetImpliedBits, r=bjorn3
bors Mar 11, 2025
7989568
intrinsics: remove unnecessary leading underscore from argument names
RalfJung Mar 12, 2025
b25a593
Remove implicit #[no_mangle] for #[rustc_std_internal_symbol]
bjorn3 Dec 2, 2023
5743d38
Rename `is_like_osx` to `is_like_darwin`
madsmtm Aug 19, 2024
2f5aa08
Avoid wrapping constant allocations in packed structs when not necessary
bjorn3 Mar 14, 2025
de1dd8b
Auto merge of #138503 - bjorn3:string_merging, r=tmiasko
bors Mar 28, 2025
3670f39
Rollup merge of #138949 - madsmtm:rename-to-darwin, r=WaffleLapkin
matthiaskrgr Apr 4, 2025
3c3a6a2
Simplify temp path creation a bit
compiler-errors Apr 6, 2025
22d3c0d
Prepend temp files with a string per invocation of rustc
compiler-errors Apr 6, 2025
90c6c9f
Merge branch 'master' into sync_from_rust_2025_04_17
antoyo Apr 17, 2025
c1d2100
Update to nightly-2025-04-17
antoyo Apr 17, 2025
cc81c70
Fix patches
antoyo Mar 27, 2025
be75a58
Fix compilation
antoyo Apr 13, 2025
5c832e5
Remove most of builtins hack since it's not necessary anymore
antoyo Mar 27, 2025
e1fa74b
Implement copysignf128
antoyo Mar 27, 2025
9a453d4
Update other patches
antoyo Mar 27, 2025
f982277
Fix libcore tests
antoyo Mar 27, 2025
5cf2bbc
Fix clippy warnings
antoyo Mar 27, 2025
ecf0a1e
Update GCC version
antoyo Apr 13, 2025
ec44cfd
Fix tests
antoyo Mar 27, 2025
bc0bc8d
Fix int_to_float_cast for f128
antoyo Mar 27, 2025
6504f4c
Format
antoyo Apr 13, 2025
bb1e6a3
Fix tests
antoyo Apr 13, 2025
0d77317
Add support for simd_insert_dyn and simd_extract_dyn
antoyo Apr 13, 2025
4b5940a
Fix overflow operations
antoyo Apr 15, 2025
06af88e
Add new failing test
antoyo Apr 15, 2025
65b87aa
Support new target builtins
antoyo Apr 17, 2025
98dd5a3
Fix for libgccjit 12
antoyo Apr 18, 2025
52b0687
Simplify handling of some SIMD intrinsics
antoyo Apr 18, 2025
db1a31c
Merge pull request #650 from rust-lang/sync_from_rust_2025_04_17
antoyo Apr 18, 2025
e4ea67b
Merge commit 'db1a31c243a649e1fe20f5466ba181da5be35c14' into subtree-…
GuillaumeGomez Apr 18, 2025
c123dc6
Fix `rustc_codegen_gcc/tests/run/return-tuple.rs` test
GuillaumeGomez Apr 18, 2025
84f5826
Fix compilation error in GCC backend
GuillaumeGomez Apr 18, 2025
cc359b8
Fix import
GuillaumeGomez Apr 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libgccjit.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e607be166673a8de9fc07f6f02c60426e556c5f2
d6f5a708104a98199ac0f01a3b6b279a0f7c66d3
74 changes: 48 additions & 26 deletions src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ use crate::type_of::LayoutGccExt;
//
// 3. Clobbers. GCC has a separate list of clobbers, and clobbers don't have indexes.
// Contrary, Rust expresses clobbers through "out" operands that aren't tied to
// a variable (`_`), and such "clobbers" do have index.
// a variable (`_`), and such "clobbers" do have index. Input operands cannot also
// be clobbered.
//
// 4. Furthermore, GCC Extended Asm does not support explicit register constraints
// (like `out("eax")`) directly, offering so-called "local register variables"
Expand Down Expand Up @@ -161,6 +162,16 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
// Also, we don't emit any asm operands immediately; we save them to
// the one of the buffers to be emitted later.

let mut input_registers = vec![];

for op in rust_operands {
if let InlineAsmOperandRef::In { reg, .. } = *op {
if let ConstraintOrRegister::Register(reg_name) = reg_to_gcc(reg) {
input_registers.push(reg_name);
}
}
}

// 1. Normal variables (and saving operands to buffers).
for (rust_idx, op) in rust_operands.iter().enumerate() {
match *op {
Expand All @@ -183,25 +194,39 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
continue;
}
(Register(reg_name), None) => {
// `clobber_abi` can add lots of clobbers that are not supported by the target,
// such as AVX-512 registers, so we just ignore unsupported registers
let is_target_supported =
reg.reg_class().supported_types(asm_arch, true).iter().any(
|&(_, feature)| {
if let Some(feature) = feature {
self.tcx
.asm_target_features(instance.def_id())
.contains(&feature)
} else {
true // Register class is unconditionally supported
}
},
);

if is_target_supported && !clobbers.contains(&reg_name) {
clobbers.push(reg_name);
if input_registers.contains(&reg_name) {
// the `clobber_abi` operand is converted into a series of
// `lateout("reg") _` operands. Of course, a user could also
// explicitly define such an output operand.
//
// GCC does not allow input registers to be clobbered, so if this out register
// is also used as an in register, do not add it to the clobbers list.
// it will be treated as a lateout register with `out_place: None`
if !late {
bug!("input registers can only be used as lateout regisers");
}
("r", dummy_output_type(self.cx, reg.reg_class()))
} else {
// `clobber_abi` can add lots of clobbers that are not supported by the target,
// such as AVX-512 registers, so we just ignore unsupported registers
let is_target_supported =
reg.reg_class().supported_types(asm_arch, true).iter().any(
|&(_, feature)| {
if let Some(feature) = feature {
self.tcx
.asm_target_features(instance.def_id())
.contains(&feature)
} else {
true // Register class is unconditionally supported
}
},
);

if is_target_supported && !clobbers.contains(&reg_name) {
clobbers.push(reg_name);
}
continue;
}
continue;
}
};

Expand Down Expand Up @@ -230,13 +255,10 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
}

InlineAsmOperandRef::InOut { reg, late, in_value, out_place } => {
let constraint =
if let ConstraintOrRegister::Constraint(constraint) = reg_to_gcc(reg) {
constraint
} else {
// left for the next pass
continue;
};
let ConstraintOrRegister::Constraint(constraint) = reg_to_gcc(reg) else {
// left for the next pass
continue;
};

// Rustc frontend guarantees that input and output types are "compatible",
// so we can just use input var's type for the output variable.
Expand Down
1 change: 0 additions & 1 deletion tests/failing-ui-tests.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
tests/ui/allocator/no_std-alloc-error-handler-custom.rs
tests/ui/allocator/no_std-alloc-error-handler-default.rs
tests/ui/asm/may_unwind.rs
tests/ui/asm/x86_64/multiple-clobber-abi.rs
tests/ui/functions-closures/parallel-codegen-closures.rs
tests/ui/linkage-attr/linkage1.rs
tests/ui/lto/dylib-works.rs
Expand Down
31 changes: 31 additions & 0 deletions tests/run/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,37 @@ fn asm() {
mem_cpy(array2.as_mut_ptr(), array1.as_ptr(), 3);
}
assert_eq!(array1, array2);

// in and clobber registers cannot overlap. This tests that the lateout register without an
// output place (indicated by the `_`) is not added to the list of clobbered registers
let x = 8;
let y: i32;
unsafe {
asm!(
"mov rax, rdi",
in("rdi") x,
lateout("rdi") _,
out("rax") y,
);
}
assert_eq!((x, y), (8, 8));

// sysv64 is the default calling convention on unix systems. The rdi register is
// used to pass arguments in the sysv64 calling convention, so this register will be clobbered
#[cfg(unix)]
{
let x = 16;
let y: i32;
unsafe {
asm!(
"mov rax, rdi",
in("rdi") x,
out("rax") y,
clobber_abi("sysv64"),
);
}
assert_eq!((x, y), (16, 16));
}
}

#[cfg(not(target_arch = "x86_64"))]
Expand Down