Skip to content

Commit

Permalink
Auto merge of #54547 - AstralSorcerer:issue-54028, r=eddyb
Browse files Browse the repository at this point in the history
Rely only on base alignment and offset for computing field alignment

Fix #54028
r? @eddyb
  • Loading branch information
bors committed Sep 28, 2018
2 parents 7d52cbc + 06b8c3e commit c222479
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/librustc_codegen_llvm/mir/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,7 @@ impl PlaceRef<'ll, 'tcx> {
let cx = bx.cx;
let field = self.layout.field(cx, ix);
let offset = self.layout.fields.offset(ix);
let effective_field_align = self.align
.min(self.layout.align)
.min(field.align)
.restrict_for_offset(offset);
let effective_field_align = self.align.restrict_for_offset(offset);

let simple = || {
// Unions and newtypes only use an offset of 0.
Expand Down
10 changes: 10 additions & 0 deletions src/test/codegen/align-struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ pub fn align64(i : i32) -> Align64 {
a64
}

// For issue 54028: make sure that we are specifying the correct alignment for fields of aligned
// structs
// CHECK-LABEL: @align64_load
#[no_mangle]
pub fn align64_load(a: Align64) -> i32 {
// CHECK: [[FIELD:%.*]] = bitcast %Align64* %{{.*}} to i32*
// CHECK: {{%.*}} = load i32, i32* [[FIELD]], align 64
a.0
}

// CHECK-LABEL: @nested64
#[no_mangle]
pub fn nested64(a: Align64, b: i32, c: i32, d: i8) -> Nested64 {
Expand Down

0 comments on commit c222479

Please sign in to comment.