about summary refs log tree commit diff
path: root/tests/codegen
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2023-09-18 16:29:50 +0000
committerCamille GILLOT <gillot.camille@gmail.com>2023-10-08 16:42:45 +0000
commit098fc9715e0f0cc3aa5c6ff0512e389c24d09254 (patch)
tree642f4f515bc68180f26ca11b21b3a0341fd5ea43 /tests/codegen
parent4f4a413fe6931d0ad9d3ac6bd20ff36398961e64 (diff)
downloadrust-098fc9715e0f0cc3aa5c6ff0512e389c24d09254.tar.gz
rust-098fc9715e0f0cc3aa5c6ff0512e389c24d09254.zip
Make FnDef 1-ZST in LLVM debuginfo.
Diffstat (limited to 'tests/codegen')
-rw-r--r--tests/codegen/debug-fndef-size.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/codegen/debug-fndef-size.rs b/tests/codegen/debug-fndef-size.rs
new file mode 100644
index 00000000000..2bfd77bade2
--- /dev/null
+++ b/tests/codegen/debug-fndef-size.rs
@@ -0,0 +1,17 @@
+// Verify that `i32::cmp` FnDef type is declared with size 0 and align 1 in LLVM debuginfo.
+// compile-flags: -O -g -Cno-prepopulate-passes
+
+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 {}, align 1
+// CHECK: call void @llvm.dbg.declare(metadata ptr %compare.dbg.spill, metadata ![[VAR:.*]], metadata !DIExpression()), !dbg !{{.*}}
+// 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)