diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-07-21 14:34:12 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-07-22 14:28:48 +0200 |
| commit | a27f3e3fd1e4d16160f8885b6b06665b5319f56c (patch) | |
| tree | b033935392cbadf6f85d2dbddf433a88e323aeeb /tests/codegen-llvm/debug-fndef-size.rs | |
| parent | ed93c1783b404d728d4809973a0550eb33cd293f (diff) | |
| download | rust-a27f3e3fd1e4d16160f8885b6b06665b5319f56c.tar.gz rust-a27f3e3fd1e4d16160f8885b6b06665b5319f56c.zip | |
Rename `tests/codegen` into `tests/codegen-llvm`
Diffstat (limited to 'tests/codegen-llvm/debug-fndef-size.rs')
| -rw-r--r-- | tests/codegen-llvm/debug-fndef-size.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/codegen-llvm/debug-fndef-size.rs b/tests/codegen-llvm/debug-fndef-size.rs new file mode 100644 index 00000000000..8f716c34e7b --- /dev/null +++ b/tests/codegen-llvm/debug-fndef-size.rs @@ -0,0 +1,20 @@ +// 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: -Copt-level=3 -g -Cno-prepopulate-passes +//@ ignore-msvc the types are mangled differently + +use std::cmp::Ordering; + +fn foo<F: FnOnce(&i32, &i32) -> Ordering>(v1: i32, v2: i32, compare: F) -> Ordering { + compare(&v1, &v2) +} + +pub fn main() { + foo(0, 1, i32::cmp); +} + +// 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: 8, dwarfAddressSpace: {{.*}}) +// CHECK: ![[VAR]] = !DILocalVariable(name: "compare", scope: !{{.*}}, file: !{{.*}}, line: {{.*}}, type: ![[TYPE]], align: 8) |
