Skip to content

GCC backend subtree update #143239

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 55 commits into from
Jun 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
6c982df
Remove get_dbg_loc from DebugInfoBuilderMethods
bjorn3 Jun 3, 2025
9eced6c
Remove type_test from IntrinsicCallBuilderMethods
bjorn3 Jun 3, 2025
46575f1
Only borrow EncodedMetadata in codegen_crate
bjorn3 May 30, 2025
7ed4c58
Move metadata object generation for dylibs to the linker code
bjorn3 May 30, 2025
0f7ec70
cg_gcc: convert to CanonAbi
workingjubilee May 21, 2025
906fc5c
Rollup merge of #141569 - workingjubilee:canonicalize-abi, r=bjorn3
matthiaskrgr Jun 3, 2025
620a4f3
Add new Tier-3 targets: `loongarch32-unknown-none*`
heiher Jan 9, 2025
3f2666c
store `target.min_global_align` as an `Align`
folkertdev Jun 7, 2025
10129e4
Use the in-tree `compiler-builtins`
tgross35 Jun 4, 2025
5f20249
Remove all unused feature gates from the compiler
bjorn3 Jun 8, 2025
732253f
Rollup merge of #142179 - folkertdev:min-global-align-parse, r=workin…
workingjubilee Jun 9, 2025
9f85857
Rollup merge of #142194 - bjorn3:less_unstable_features, r=jieyouxu
workingjubilee Jun 9, 2025
f485c26
-Zretpoline and -Zretpoline-external-thunk flags (target modifiers) t…
azhogin Jan 15, 2025
98e21c8
Rollup merge of #141993 - tgross35:use-in-tree-builtins, r=bjorn3
tgross35 Jun 9, 2025
fa425db
Simplify implementation of Rust intrinsics by using type parameters i…
sayantn May 30, 2025
f5c6288
intrinsics: rename min_align_of to align_of
RalfJung Jun 12, 2025
65042d6
add `extern "custom"` functions
folkertdev May 7, 2025
1ff33b5
Unimplement unsized_locals
mejrs Jun 12, 2025
ad90ea8
Rollup merge of #135927 - azhogin:azhogin/retpoline, r=davidtwco
matthiaskrgr Jun 13, 2025
3766fb2
Rollup merge of #140770 - folkertdev:custom-abi, r=tgross35
matthiaskrgr Jun 13, 2025
baaf8da
Auto merge of #142443 - matthiaskrgr:rollup-l1l6d0v, r=matthiaskrgr
bors Jun 13, 2025
4ffcf80
Rollup merge of #141811 - mejrs:bye_locals, r=compiler-errors
matthiaskrgr Jun 14, 2025
3c96f6e
Remove all support for wasm's legacy ABI
bjorn3 Dec 6, 2024
5b660c5
Auto merge of #142259 - sayantn:simplify-intrinsics, r=workingjubilee
bors Jun 14, 2025
29e0e4f
Rollup merge of #133952 - bjorn3:remove_wasm_legacy_abi, r=alexcrichton
fmease Jun 15, 2025
8f47346
Rollup merge of #141769 - bjorn3:codegen_metadata_module_rework, r=wo…
fmease Jun 15, 2025
308ca33
Fix RISC-V C function ABI when passing/returning structs containing f…
beetrees Apr 3, 2025
5615d05
Change __rust_no_alloc_shim_is_unstable to be a function
dpaoliello May 15, 2025
e9d795d
cranelift/gcc: `{Meta,Pointee,}Sized` in minicore
davidtwco Mar 5, 2025
2811b34
Auto merge of #137944 - davidtwco:sized-hierarchy, r=oli-obk
bors Jun 17, 2025
265f4a7
Auto merge of #141061 - dpaoliello:shimasfn, r=bjorn3
bors Jun 18, 2025
efb7997
Merge commit 'fda0bb9588912a3e0606e880ca9f6e913cf8a5a4' into subtree-…
GuillaumeGomez Jun 18, 2025
6bbf8b1
GCC backend: Remove `add_eval` if no function is created
GuillaumeGomez Jun 18, 2025
25eb2ee
move cfg(target_feature) computation into shared place
RalfJung May 10, 2025
63c9292
move -Ctarget-feature handling into shared code
RalfJung May 23, 2025
3a0881c
cg_gcc: properly populate cfg(target_features) with -Ctarget-features
RalfJung May 11, 2025
1aabebc
various minor target feature cleanups
RalfJung Jun 14, 2025
f8db66b
Remove dead instructions in terminate blocks
Mark-Simulacrum Jun 22, 2025
7014ca4
rustc_codegen_gcc: Fix clippy::manual_is_multiple_of
flip1995 Jun 27, 2025
a836612
Merge branch 'master' into sync_from_rust_2025_06_28
antoyo Jun 28, 2025
a80f3c4
Fix clippy warnings
antoyo Jun 28, 2025
38fa4a4
Fix sysroot Cargo.toml for compiler-builtins
antoyo Jun 28, 2025
e3bb127
Add support for copysignf16 intrinsic
antoyo Jun 28, 2025
fe8b5e6
Remove now useless patch for run-make test
antoyo Jun 28, 2025
99780df
Fix intrinsic copysignf128
antoyo Jun 29, 2025
769fb75
Fix exactudiv and exactsdiv for gcc without 128-bit integers
antoyo Jun 29, 2025
67d8469
Add support for a few missing LLVM intrinsics
antoyo Jun 29, 2025
88db589
Changed intrinsic generation to include full intrinsic names in panic…
FractalFir Jun 29, 2025
c57393e
Regenerated intrinsics
FractalFir Jun 29, 2025
4347a92
Fix handling of __builtin_ia32_rdtscp
antoyo Jun 29, 2025
15d23bd
Merge pull request #723 from rust-lang/sync_from_rust_2025_06_28
antoyo Jun 30, 2025
1926f60
Fix const_undef
antoyo Jun 30, 2025
ce73bab
Merge pull request #726 from rust-lang/fix/const_undef
antoyo Jun 30, 2025
4b5c44b
Merge pull request #725 from FractalFir/intrinsic_fix
antoyo Jun 30, 2025
666934a
Merge commit '4b5c44b14166083eef8d71f15f5ea1f53fc976a0' into subtree-…
GuillaumeGomez Jun 30, 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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ resolver = "2"

[dependencies]
core = { path = "./sysroot_src/library/core" }
compiler_builtins = { path = "./sysroot_src/library/compiler-builtins/compiler-builtins" }
alloc = { path = "./sysroot_src/library/alloc" }
std = { path = "./sysroot_src/library/std", features = ["panic_unwind", "backtrace"] }
test = { path = "./sysroot_src/library/test" }
Expand Down
28 changes: 2 additions & 26 deletions compiler/rustc_codegen_gcc/build_system/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use crate::build;
use crate::config::{Channel, ConfigInfo};
use crate::utils::{
create_dir, get_sysroot_dir, get_toolchain, git_clone, git_clone_root_dir, remove_file,
run_command, run_command_with_env, run_command_with_output, run_command_with_output_and_env,
rustc_version_info, split_args, walk_dir,
run_command, run_command_with_env, run_command_with_output_and_env, rustc_version_info,
split_args, walk_dir,
};

type Env = HashMap<String, String>;
Expand Down Expand Up @@ -485,30 +485,6 @@ fn setup_rustc(env: &mut Env, args: &TestArg) -> Result<PathBuf, String> {
run_command_with_output_and_env(&[&"git", &"checkout"], rust_dir, Some(env))?;
}

let mut patches = Vec::new();
walk_dir(
"patches/tests",
&mut |_| Ok(()),
&mut |file_path: &Path| {
patches.push(file_path.to_path_buf());
Ok(())
},
false,
)?;
patches.sort();
// TODO: remove duplication with prepare.rs by creating a apply_patch function in the utils
// module.
for file_path in patches {
println!("[GIT] apply `{}`", file_path.display());
let path = Path::new("../..").join(file_path);
run_command_with_output(&[&"git", &"apply", &path], rust_dir)?;
run_command_with_output(&[&"git", &"add", &"-A"], rust_dir)?;
run_command_with_output(
&[&"git", &"commit", &"--no-gpg-sign", &"-m", &format!("Patch {}", path.display())],
rust_dir,
)?;
}

let cargo = String::from_utf8(
run_command_with_env(&[&"rustup", &"which", &"cargo"], rust_dir, Some(env))?.stdout,
)
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2025-06-02"
channel = "nightly-2025-06-28"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
4 changes: 3 additions & 1 deletion compiler/rustc_codegen_gcc/src/abi.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#[cfg(feature = "master")]
use gccjit::FnAttribute;
use gccjit::{ToLValue, ToRValue, Type};
use rustc_abi::{ArmCall, CanonAbi, InterruptKind, Reg, RegKind, X86Call};
#[cfg(feature = "master")]
use rustc_abi::{ArmCall, CanonAbi, InterruptKind, X86Call};
use rustc_abi::{Reg, RegKind};
use rustc_codegen_ssa::traits::{AbiBuilderMethods, BaseTypeCodegenMethods};
use rustc_data_structures::fx::FxHashSet;
use rustc_middle::bug;
Expand Down
46 changes: 11 additions & 35 deletions compiler/rustc_codegen_gcc/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,11 +538,6 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
}

fn ret(&mut self, mut value: RValue<'gcc>) {
if self.structs_as_pointer.borrow().contains(&value) {
// NOTE: hack to workaround a limitation of the rustc API: see comment on
// CodegenCx.structs_as_pointer
value = value.dereference(self.location).to_rvalue();
}
let expected_return_type = self.current_func().get_return_type();
if !expected_return_type.is_compatible_with(value.get_type()) {
// NOTE: due to opaque pointers now being used, we need to cast here.
Expand Down Expand Up @@ -700,7 +695,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
let a = self.gcc_int_cast(a, a_type);
let b_type = b.get_type().to_unsigned(self);
let b = self.gcc_int_cast(b, b_type);
a / b
self.gcc_udiv(a, b)
}

fn sdiv(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
Expand All @@ -712,8 +707,8 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
// FIXME(antoyo): rustc_codegen_ssa::mir::intrinsic uses different types for a and b but they
// should be the same.
let typ = a.get_type().to_signed(self);
let b = self.context.new_cast(self.location, b, typ);
a / b
let b = self.gcc_int_cast(b, typ);
self.gcc_sdiv(a, b)
}

fn fdiv(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
Expand Down Expand Up @@ -1119,13 +1114,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
// TODO(antoyo)
}

fn store(&mut self, mut val: RValue<'gcc>, ptr: RValue<'gcc>, align: Align) -> RValue<'gcc> {
if self.structs_as_pointer.borrow().contains(&val) {
// NOTE: hack to workaround a limitation of the rustc API: see comment on
// CodegenCx.structs_as_pointer
val = val.dereference(self.location).to_rvalue();
}

fn store(&mut self, val: RValue<'gcc>, ptr: RValue<'gcc>, align: Align) -> RValue<'gcc> {
self.store_with_flags(val, ptr, align, MemFlags::empty())
}

Expand Down Expand Up @@ -1508,16 +1497,6 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
element.get_address(self.location)
} else if value_type.dyncast_vector().is_some() {
panic!();
} else if let Some(pointer_type) = value_type.get_pointee() {
if let Some(struct_type) = pointer_type.is_struct() {
// NOTE: hack to workaround a limitation of the rustc API: see comment on
// CodegenCx.structs_as_pointer
aggregate_value
.dereference_field(self.location, struct_type.get_field(idx as i32))
.to_rvalue()
} else {
panic!("Unexpected type {:?}", value_type);
}
} else if let Some(struct_type) = value_type.is_struct() {
aggregate_value
.access_field(self.location, struct_type.get_field(idx as i32))
Expand All @@ -1537,21 +1516,18 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
assert_eq!(idx as usize as u64, idx);
let value_type = aggregate_value.get_type();

let new_val = self.current_func().new_local(None, value_type, "aggregate_value");
self.block.add_assignment(None, new_val, aggregate_value);

let lvalue = if value_type.dyncast_array().is_some() {
let index = self
.context
.new_rvalue_from_long(self.u64_type, i64::try_from(idx).expect("i64::try_from"));
self.context.new_array_access(self.location, aggregate_value, index)
self.context.new_array_access(self.location, new_val, index)
} else if value_type.dyncast_vector().is_some() {
panic!();
} else if let Some(pointer_type) = value_type.get_pointee() {
if let Some(struct_type) = pointer_type.is_struct() {
// NOTE: hack to workaround a limitation of the rustc API: see comment on
// CodegenCx.structs_as_pointer
aggregate_value.dereference_field(self.location, struct_type.get_field(idx as i32))
} else {
panic!("Unexpected type {:?}", value_type);
}
} else if let Some(struct_type) = value_type.is_struct() {
new_val.access_field(None, struct_type.get_field(idx as i32))
} else {
panic!("Unexpected type {:?}", value_type);
};
Expand All @@ -1568,7 +1544,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {

self.llbb().add_assignment(self.location, lvalue, value);

aggregate_value
new_val.to_rvalue()
}

fn set_personality_fn(&mut self, _personality: Function<'gcc>) {
Expand Down
10 changes: 1 addition & 9 deletions compiler/rustc_codegen_gcc/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,7 @@ impl<'gcc, 'tcx> ConstCodegenMethods for CodegenCx<'gcc, 'tcx> {

fn const_undef(&self, typ: Type<'gcc>) -> RValue<'gcc> {
let local = self.current_func.borrow().expect("func").new_local(None, typ, "undefined");
if typ.is_struct().is_some() {
// NOTE: hack to workaround a limitation of the rustc API: see comment on
// CodegenCx.structs_as_pointer
let pointer = local.get_address(None);
self.structs_as_pointer.borrow_mut().insert(pointer);
pointer
} else {
local.to_rvalue()
}
local.to_rvalue()
}

fn const_poison(&self, typ: Type<'gcc>) -> RValue<'gcc> {
Expand Down
9 changes: 0 additions & 9 deletions compiler/rustc_codegen_gcc/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,6 @@ pub struct CodegenCx<'gcc, 'tcx> {

pub pointee_infos: RefCell<FxHashMap<(Ty<'tcx>, Size), Option<PointeeInfo>>>,

/// NOTE: a hack is used because the rustc API is not suitable to libgccjit and as such,
/// `const_undef()` returns struct as pointer so that they can later be assigned a value (in
/// e.g. Builder::insert_value).
/// As such, this set remembers which of these pointers were returned by this function so that
/// they can be dereferenced later.
/// FIXME(antoyo): fix the rustc API to avoid having this hack.
pub structs_as_pointer: RefCell<FxHashSet<RValue<'gcc>>>,

#[cfg(feature = "master")]
pub cleanup_blocks: RefCell<FxHashSet<Block<'gcc>>>,
/// The alignment of a u128/i128 type.
Expand Down Expand Up @@ -304,7 +296,6 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
#[cfg(feature = "master")]
rust_try_fn: Cell::new(None),
pointee_infos: Default::default(),
structs_as_pointer: Default::default(),
#[cfg(feature = "master")]
cleanup_blocks: Default::default(),
};
Expand Down
Loading
Loading