Skip to content

Fix passing structs containing multiple f32s to the FFI #7457

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

Closed
wants to merge 2 commits into from
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
1 change: 1 addition & 0 deletions src/etc/ctags.rust
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
--regex-rust=/[ \t]*static[ \t]+([a-zA-Z0-9_]+)/\1/m,consts/
--regex-rust=/[ \t]*trait[ \t]+([a-zA-Z0-9_]+)/\1/m,traits/
--regex-rust=/[ \t]*impl[ \t]+([a-zA-Z0-9_]+)/\1/m,impls/
--regex-rust=/[ \t]*macro_rules![ \t]+([a-zA-Z0-9_]+)/\1/m,macros/
14 changes: 5 additions & 9 deletions src/librustc/middle/trans/cabi_x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,10 @@ fn classify_ty(ty: Type) -> ~[RegClass] {
Float => 4,
Double => 8,
Struct => {
let str_tys = ty.field_types();
if ty.is_packed() {
let str_tys = ty.field_types();
str_tys.iter().fold(0, |s, t| s + ty_size(*t))
} else {
let str_tys = ty.field_types();
let size = str_tys.iter().fold(0, |s, t| align(s, *t) + ty_size(*t));
align(size, ty)
}
Expand Down Expand Up @@ -236,9 +235,7 @@ fn classify_ty(ty: Type) -> ~[RegClass] {
let mut i = 0u;
let ty_kind = ty.kind();
let e = cls.len();
if cls.len() > 2u &&
(ty_kind == Struct ||
ty_kind == Array) {
if cls.len() > 2u && (ty_kind == Struct || ty_kind == Array) {
if cls[i].is_sse() {
i += 1u;
while i < e {
Expand All @@ -265,7 +262,7 @@ fn classify_ty(ty: Type) -> ~[RegClass] {
return;
}
if cls[i] == SSEUp {
cls[i] = SSEInt;
cls[i] = SSEDv;
} else if cls[i].is_sse() {
i += 1;
while i != e && cls[i] == SSEUp { i += 1u; }
Expand All @@ -283,7 +280,6 @@ fn classify_ty(ty: Type) -> ~[RegClass] {
let mut cls = vec::from_elem(words, NoClass);
if words > 4 {
all_mem(cls);
let cls = cls;
return cls;
}
classify(ty, cls, 0, 0);
Expand Down Expand Up @@ -312,8 +308,8 @@ fn llreg_ty(cls: &[RegClass]) -> Type {
tys.push(Type::i64());
}
SSEFv => {
let vec_len = llvec_len(cls.tailn(i + 1u)) * 2u;
let vec_ty = Type::vector(&Type::f32(), vec_len as u64);
let vec_len = llvec_len(cls.tailn(i + 1u));
let vec_ty = Type::vector(&Type::f32(), (vec_len * 2u) as u64);
tys.push(vec_ty);
i += vec_len;
loop;
Expand Down