Skip to content

Commit 6f5b4e3

Browse files
committed
Add test for method debuginfo declaration.
We've investigated one reason why debugging information often goes wrong at https://reviews.llvm.org/D152095. > LLVM can't handle IR where subprogram definitions are nested within DICompositeType when doing LTO builds, > because there's no good way to cross the CU boundary to insert a nested DISubprogram definition in one CU into a type defined in another CU.
1 parent f1b8548 commit 6f5b4e3

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/codegen/method-declaration.rs

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// compile-flags: -g -Cno-prepopulate-passes
2+
3+
// Verify that we added a declaration for a method.
4+
5+
// CHECK: define{{.*}}@method{{.*}} !dbg ![[METHOD_DEF_DBG:[0-9]+]]
6+
// CHECK: define{{.*}}@function{{.*}} !dbg ![[FUNC_DEF_DBG:[0-9]+]]
7+
8+
#![crate_type = "lib"]
9+
10+
// CHECK-DAG: ![[FOO_DBG:[0-9]+]] = !DICompositeType(tag: {{.*}} name: "Foo", {{.*}} identifier:
11+
pub struct Foo;
12+
13+
impl Foo {
14+
// CHECK-DAG: ![[METHOD_DEF_DBG]] = distinct !DISubprogram(name: "method"{{.*}}, scope: ![[FOO_DBG]]{{.*}}DISPFlagDefinition{{.*}}, declaration: ![[METHOD_DECL_DBG:[0-9]+]]
15+
// CHECK-DAG: ![[METHOD_DECL_DBG]] = !DISubprogram(name: "method"{{.*}}, scope: ![[FOO_DBG]]
16+
#[no_mangle]
17+
pub fn method() {}
18+
}
19+
20+
// CHECK: ![[FUNC_DEF_DBG]] = distinct !DISubprogram(name: "function"
21+
// CHECK-NOT: declaration
22+
// CHECK-SAME: DISPFlagDefinition
23+
// CHECK-NOT: declaration
24+
// CHECK-SAME: )
25+
#[no_mangle]
26+
pub fn function() {}

0 commit comments

Comments
 (0)