Skip to content

Subtree sync for rustc_codegen_cranelift #137078

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 25 commits into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
04e580f
Merge commit '8332329f83d4ef34479fec67cc21b21246dca6b5' into sync_cg_…
bjorn3 Feb 7, 2025
7d73de8
Update `compiler-builtins` to 0.1.146
tgross35 Feb 7, 2025
28a241f
Merge branch 'sync_from_rust'
bjorn3 Feb 7, 2025
6bd92ef
Rustfmt
bjorn3 Feb 8, 2025
f97679d
cg_clif: stop worrying about `Conv::PtxKernel`
workingjubilee Feb 10, 2025
732132f
Extend the renaming to coerce_unsafe_ptr
1c3t3a Jan 24, 2025
603534f
Rollup merge of #136714 - tgross35:update-builtins, r=tgross35
matthiaskrgr Feb 10, 2025
4836002
Sync from rust 92bedea1c51e3a969d60972be854506ffd8c5cb6
bjorn3 Feb 12, 2025
ecad689
Rustup to rustc 1.86.0-nightly (92bedea1c 2025-02-11)
bjorn3 Feb 12, 2025
159080c
Auto merge of #135994 - 1c3t3a:rename-unsafe-ptr, r=oli-obk
bors Feb 12, 2025
7b12050
Rollup merge of #136807 - workingjubilee:merge-gpus-to-get-the-arcrad…
jhpratt Feb 13, 2025
f9116db
Auto merge of #136954 - jhpratt:rollup-koefsot, r=jhpratt
bors Feb 13, 2025
c6ddd33
Implement and use BikeshedGuaranteedNoDrop for union/unsafe field val…
compiler-errors Feb 6, 2025
7a4b898
Rollup merge of #136660 - compiler-errors:BikeshedGuaranteedNoDrop, r…
jhpratt Feb 13, 2025
c27715b
Use abi rather than preferred alignment everywhere
bjorn3 Feb 13, 2025
27e8329
Slightly optimize dynamic realignment in create_stack_slot
bjorn3 Feb 13, 2025
cdadd5f
Use correct size for stack slot in inline asm codegen
bjorn3 Feb 13, 2025
8dda1eb
Update rustfmt.toml to match the rust repo
bjorn3 Feb 13, 2025
66bcca1
Make `-O` mean `-C opt-level=3`
clubby789 Jan 13, 2025
c0c106d
Sync from rust a567209daab72b7ea59eac533278064396bb0534
bjorn3 Feb 14, 2025
aa9cbd7
Rustup to rustc 1.86.0-nightly (a567209da 2025-02-13)
bjorn3 Feb 14, 2025
de27d85
Update to newer Ubuntu in CI for distributing precompiled artifacts
bjorn3 Feb 14, 2025
9139707
Sync from rust d8810e3e2dab96778d20dd6d746ff95465515509
bjorn3 Feb 15, 2025
557ed8e
Rustup to rustc 1.86.0-nightly (d8810e3e2 2025-02-14)
bjorn3 Feb 15, 2025
7a6206e
Merge commit '557ed8ebb7e981817d03c87352892c394183dd70' into sync_cg_…
bjorn3 Feb 15, 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
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_cranelift/.github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ jobs:
fail-fast: false
matrix:
include:
# FIXME update at some point in the future once most distros use a newer glibc
- os: ubuntu-20.04
# Intentionally using an older ubuntu version to lower the glibc requirements of the distributed cg_clif
- os: ubuntu-22.04
env:
TARGET_TRIPLE: x86_64-unknown-linux-gnu
- os: macos-latest
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "nightly-2025-02-07"
channel = "nightly-2025-02-15"
components = ["rust-src", "rustc-dev", "llvm-tools"]
profile = "minimal"
3 changes: 2 additions & 1 deletion compiler/rustc_codegen_cranelift/rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ ignore = [
]

# Matches rustfmt.toml of rustc
version = "Two"
style_edition = "2024"
use_small_heuristics = "Max"
merge_derives = false
group_imports = "StdExternalCrate"
imports_granularity = "Module"
use_field_init_shorthand = true
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ pub(super) fn from_casted_value<'tcx>(
// It may also be smaller for example when the type is a wrapper around an integer with a
// larger alignment than the integer.
std::cmp::max(abi_param_size, layout_size),
u32::try_from(layout.align.pref.bytes()).unwrap(),
u32::try_from(layout.align.abi.bytes()).unwrap(),
);
let mut offset = 0;
let mut block_params_iter = block_params.iter().copied();
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_codegen_cranelift/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,11 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
}

pub(crate) fn create_stack_slot(&mut self, size: u32, align: u32) -> Pointer {
assert!(
size % align == 0,
"size must be a multiple of alignment (size={size}, align={align})"
);

let abi_align = if self.tcx.sess.target.arch == "s390x" { 8 } else { 16 };
if align <= abi_align {
let stack_slot = self.bcx.create_sized_stack_slot(StackSlotData {
Expand All @@ -403,7 +408,7 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
align_shift: 4,
});
let base_ptr = self.bcx.ins().stack_addr(self.pointer_type, stack_slot, 0);
let misalign_offset = self.bcx.ins().urem_imm(base_ptr, i64::from(align));
let misalign_offset = self.bcx.ins().band_imm(base_ptr, i64::from(align - 1));
let realign_offset = self.bcx.ins().irsub_imm(misalign_offset, i64::from(align));
Pointer::new(self.bcx.ins().iadd(base_ptr, realign_offset))
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ impl DebugContext {
entry.set(gimli::DW_AT_decl_file, AttributeValue::FileIndex(Some(file_id)));
entry.set(gimli::DW_AT_decl_line, AttributeValue::Udata(line));

entry.set(gimli::DW_AT_alignment, AttributeValue::Udata(static_layout.align.pref.bytes()));
entry.set(gimli::DW_AT_alignment, AttributeValue::Udata(static_layout.align.abi.bytes()));

let mut expr = Expression::new();
expr.op_addr(address_for_data(data_id));
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_cranelift/src/debuginfo/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl DebugContext {
let tuple_entry = self.dwarf.unit.get_mut(tuple_type_id);
tuple_entry.set(gimli::DW_AT_name, AttributeValue::StringRef(self.dwarf.strings.add(name)));
tuple_entry.set(gimli::DW_AT_byte_size, AttributeValue::Udata(layout.size.bytes()));
tuple_entry.set(gimli::DW_AT_alignment, AttributeValue::Udata(layout.align.pref.bytes()));
tuple_entry.set(gimli::DW_AT_alignment, AttributeValue::Udata(layout.align.abi.bytes()));

for (i, (ty, dw_ty)) in components.into_iter().enumerate() {
let member_id = self.dwarf.unit.add(tuple_type_id, gimli::DW_TAG_member);
Expand All @@ -179,7 +179,7 @@ impl DebugContext {
member_entry.set(
gimli::DW_AT_alignment,
AttributeValue::Udata(
FullyMonomorphizedLayoutCx(tcx).layout_of(ty).align.pref.bytes(),
FullyMonomorphizedLayoutCx(tcx).layout_of(ty).align.abi.bytes(),
),
);
member_entry.set(
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_codegen_cranelift/src/inline_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,8 @@ fn call_inline_asm<'tcx>(
inputs: Vec<(Size, Value)>,
outputs: Vec<(Size, CPlace<'tcx>)>,
) {
let stack_slot = fx.create_stack_slot(u32::try_from(slot_size.bytes()).unwrap(), 16);
let stack_slot =
fx.create_stack_slot(u32::try_from(slot_size.bytes().next_multiple_of(16)).unwrap(), 16);

let inline_asm_func = fx
.module
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_cranelift/src/value_and_place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl<'tcx> CValue<'tcx> {
/// The is represented by a dangling pointer of suitable alignment.
pub(crate) fn zst(layout: TyAndLayout<'tcx>) -> CValue<'tcx> {
assert!(layout.is_zst());
CValue::by_ref(crate::Pointer::dangling(layout.align.pref), layout)
CValue::by_ref(crate::Pointer::dangling(layout.align.abi), layout)
}

pub(crate) fn layout(&self) -> TyAndLayout<'tcx> {
Expand Down Expand Up @@ -392,7 +392,7 @@ impl<'tcx> CPlace<'tcx> {
assert!(layout.is_sized());
if layout.size.bytes() == 0 {
return CPlace {
inner: CPlaceInner::Addr(Pointer::dangling(layout.align.pref), None),
inner: CPlaceInner::Addr(Pointer::dangling(layout.align.abi), None),
layout,
};
}
Expand All @@ -405,7 +405,7 @@ impl<'tcx> CPlace<'tcx> {

let stack_slot = fx.create_stack_slot(
u32::try_from(layout.size.bytes()).unwrap(),
u32::try_from(layout.align.pref.bytes()).unwrap(),
u32::try_from(layout.align.abi.bytes()).unwrap(),
);
CPlace { inner: CPlaceInner::Addr(stack_slot, None), layout }
}
Expand Down
Loading