Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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 Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ dependencies = [

[[package]]
name = "gccjit"
version = "4.0.0"
version = "4.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be5dafc4e649cb4a363e95a5960ef50b0c6f1b8e136ff8eb2e928b40353b5d8b"
checksum = "859af1dd2815fd0f8ca97f5917a595f18c415692b07e58993a6ad34ff13204d5"
dependencies = [
"gccjit_sys",
]
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ default = ["master"]
[dependencies]
object = { version = "0.37.0", default-features = false, features = ["std", "read"] }
tempfile = "3.20"
gccjit = { version = "4.0.0", features = ["dlopen"] }
gccjit = { version = "4.1.0", features = ["dlopen"] }
#gccjit = { git = "https://github.com/rust-lang/gccjit.rs", branch = "error-dlopen", features = ["dlopen"] }

# Local copy.
Expand Down
13 changes: 10 additions & 3 deletions src/abi.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(feature = "master")]
use gccjit::FnAttribute;
use gccjit::{FnAttribute, TypeAttribute};
use gccjit::{ToLValue, ToRValue, Type};
#[cfg(feature = "master")]
use rustc_abi::{ArmCall, CanonAbi, InterruptKind, X86Call};
Expand Down Expand Up @@ -187,7 +187,7 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
let ty = cast.gcc_type(cx);
apply_attrs(ty, &cast.attrs, argument_tys.len())
}
PassMode::Indirect { attrs: _, meta_attrs: None, on_stack: true } => {
PassMode::Indirect { attrs, meta_attrs: None, on_stack: true } => {
let x86_interrupt_first_arg = {
#[cfg(feature = "master")]
{
Expand All @@ -211,7 +211,14 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
} else {
// This is a "byval" argument, so we don't apply the `restrict` attribute on it.
on_stack_param_indices.insert(argument_tys.len());
arg.layout.gcc_type(cx)
let ty = arg.layout.gcc_type(cx);
#[cfg(feature = "master")]
if let Some(align) = attrs.pointee_align {
ty.add_attribute(TypeAttribute::Aligned(align.bytes() as u32));
}
#[cfg(not(feature = "master"))]
let _ = attrs;
ty
}
}
PassMode::Direct(attrs) => {
Expand Down
2 changes: 2 additions & 0 deletions src/gcc_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@
context.add_command_line_option("-fno-strict-aliasing");
// NOTE: Rust relies on LLVM doing wrapping on overflow.
context.add_command_line_option("-fwrapv");
// NOTE: This is needed to hide a warning caused by the alignment fix on byval arguments.
context.add_command_line_option("-Wno-psabi");

Check warning on line 197 in src/gcc_util.rs

View workflow job for this annotation

GitHub Actions / spell_check

Unknown word (psabi)

if let Some(model) = sess.code_model() {
use rustc_target::spec::CodeModel;
Expand Down
41 changes: 41 additions & 0 deletions tests/run/overaligned_byval_arg.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Compiler:
//
// Run-time:
// status: 0

#![feature(no_core)]
#![no_std]
#![no_core]
#![no_main]

extern crate mini_core;
use mini_core::*;

#[repr(C)]
struct Big {
a: i64,
b: i64,
c: i64,
}

#[repr(C, align(64))]
struct Aligned {
x: i32,
}

#[inline(never)]
#[no_mangle]
extern "C" fn check(_b1: Big, a1: Aligned, _b2: Big, a2: Aligned) -> i32 {
if (&a1 as *const Aligned as usize) % 64 != 0 {
return 1;
}
if (&a2 as *const Aligned as usize) % 64 != 0 {
return 2;
}
0
}

#[no_mangle]
extern "C" fn main(_argc: i32, _argv: *const *const u8) -> i32 {
check(Big { a: 1, b: 2, c: 3 }, Aligned { x: 42 }, Big { a: 4, b: 5, c: 6 }, Aligned { x: 43 })
}
Loading