Skip to content

Commit

Permalink
librustc: Fix field offsets for packed structs.
Browse files Browse the repository at this point in the history
  • Loading branch information
luqmana committed Aug 18, 2014
1 parent 7074592 commit 82fa436
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/librustc/middle/trans/cabi_x86_64.rs
Expand Up @@ -176,11 +176,15 @@ fn classify_ty(ty: Type) -> Vec<RegClass> {
}

fn classify_struct(tys: &[Type],
cls: &mut [RegClass], i: uint,
off: uint) {
cls: &mut [RegClass],
i: uint,
off: uint,
packed: bool) {
let mut field_off = off;
for ty in tys.iter() {
field_off = align(field_off, *ty);
if !packed {
field_off = align(field_off, *ty);
}
classify(*ty, cls, i, field_off);
field_off += ty_size(*ty);
}
Expand Down Expand Up @@ -219,7 +223,7 @@ fn classify_ty(ty: Type) -> Vec<RegClass> {
unify(cls, ix + off / 8u, SSEDs);
}
Struct => {
classify_struct(ty.field_types().as_slice(), cls, ix, off);
classify_struct(ty.field_types().as_slice(), cls, ix, off, ty.is_packed());
}
Array => {
let len = ty.array_length();
Expand Down

0 comments on commit 82fa436

Please sign in to comment.