Rollup merge of #136640 - Zalathar:debuginfo-align-bits, r=compiler-errors

Debuginfo for function ZSTs should have alignment of 8 bits, not 1 bit

In #116096, function ZSTs were made to have debuginfo that gives them an alignment of “1”. But because alignment in LLVM debuginfo is denoted in *bits*, not bytes, this resulted in an alignment specification of 1 bit instead of 1 byte.

I don't know whether this has any practical consequences, but I noticed that a test started failing when I accidentally fixed the mistake while working on #136632, so I extracted the fix (and the test adjustment) to this PR.
This commit is contained in:
Matthias Krüger 2025-02-08 03:58:45 +01:00 committed by GitHub
commit 93b194516a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 11 deletions

View file

@ -1,4 +1,6 @@
// Verify that `i32::cmp` FnDef type is declared with size 0 and align 1 in LLVM debuginfo.
// Verify that `i32::cmp` FnDef type is declared with a size of 0 and an
// alignment of 8 bits (1 byte) in LLVM debuginfo.
//@ compile-flags: -O -g -Cno-prepopulate-passes
//@ ignore-msvc the types are mangled differently
@ -14,5 +16,5 @@ pub fn main() {
// CHECK: %compare.dbg.spill = alloca [0 x i8], align 1
// CHECK: dbg{{.}}declare({{(metadata )?}}ptr %compare.dbg.spill, {{(metadata )?}}![[VAR:.*]], {{(metadata )?}}!DIExpression()
// CHECK: ![[TYPE:.*]] = !DIDerivedType(tag: DW_TAG_pointer_type, name: "fn(&i32, &i32) -> core::cmp::Ordering", baseType: !{{.*}}, align: 1, dwarfAddressSpace: {{.*}})
// CHECK: ![[VAR]] = !DILocalVariable(name: "compare", scope: !{{.*}}, file: !{{.*}}, line: {{.*}}, type: ![[TYPE]], align: 1)
// CHECK: ![[TYPE:.*]] = !DIDerivedType(tag: DW_TAG_pointer_type, name: "fn(&i32, &i32) -> core::cmp::Ordering", baseType: !{{.*}}, align: 8, dwarfAddressSpace: {{.*}})
// CHECK: ![[VAR]] = !DILocalVariable(name: "compare", scope: !{{.*}}, file: !{{.*}}, line: {{.*}}, type: ![[TYPE]], align: 8)