Skip to content

Commit 82a1d79

Browse files
authored
Rollup merge of rust-lang#97846 - pcwalton:align-bits, r=michaelwoerister
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
2 parents 29c6f5f + fe533e8 commit 82a1d79

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,7 @@ pub fn build_global_var_di_node<'ll>(cx: &CodegenCx<'ll, '_>, def_id: DefId, glo
13651365
is_local_to_unit,
13661366
global,
13671367
None,
1368-
global_align.bytes() as u32,
1368+
global_align.bits() as u32,
13691369
);
13701370
}
13711371
}

src/test/codegen/debug-alignment.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Verifies that DWARF alignment is specified properly.
2+
//
3+
// compile-flags: -C debuginfo=2
4+
#![crate_type = "lib"]
5+
6+
// CHECK: !DIGlobalVariable
7+
// CHECK: align: 32
8+
pub static A: u32 = 1;

0 commit comments

Comments
 (0)