Skip to content

Commit

Permalink
Rollup merge of #97846 - pcwalton:align-bits, r=michaelwoerister
Browse files Browse the repository at this point in the history
Specify DWARF alignment in bits, not bytes.

In DWARF, alignment of types is specified in bits, as is made clear by the
parameter name `AlignInBits`. However, `rustc` was incorrectly passing a byte
alignment. This commit fixes that.

This was noticed in upstream LLVM when I tried to check in a test consisting of
LLVM IR generated from `rustc` and it triggered assertions [1].

[1]: https://reviews.llvm.org/D126835
  • Loading branch information
Dylan-DPC committed Jun 8, 2022
2 parents 29c6f5f + fe533e8 commit 82a1d79
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@ pub fn build_global_var_di_node<'ll>(cx: &CodegenCx<'ll, '_>, def_id: DefId, glo
is_local_to_unit,
global,
None,
global_align.bytes() as u32,
global_align.bits() as u32,
);
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/test/codegen/debug-alignment.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Verifies that DWARF alignment is specified properly.
//
// compile-flags: -C debuginfo=2
#![crate_type = "lib"]

// CHECK: !DIGlobalVariable
// CHECK: align: 32
pub static A: u32 = 1;

0 comments on commit 82a1d79

Please sign in to comment.