File: coro-split-dbg-nested-struct.ll

package info (click to toggle)
llvm-toolchain-21 1%3A21.1.6-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,245,028 kB
  • sloc: cpp: 7,619,726; ansic: 1,434,018; asm: 1,058,748; python: 252,740; f90: 94,671; objc: 70,685; lisp: 42,813; pascal: 18,401; sh: 8,601; ml: 5,111; perl: 4,720; makefile: 3,675; awk: 3,523; javascript: 2,409; xml: 892; fortran: 770
file content (61 lines) | stat: -rw-r--r-- 2,929 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
; RUN: opt < %s -passes='cgscc(coro-split)' -S | FileCheck %s

; Test that nested structs in coroutine frames have correct debug info scoping.

; Minimal nested struct types that used to trigger a scoping issue:
; we used to set the wrong `scope` for the `DIDerivedType` member entries of the `DICompositeType`
; as well as the `scope` for `DICompositeType` for the inner struct itself.
%"struct.Inner" = type { i32, ptr }
%"struct.Outer" = type { %"struct.Inner", i64 }
%"class.Promise" = type { %"struct.Outer" }

define void @test_coro_function() presplitcoroutine !dbg !10 {
entry:
  %__promise = alloca %"class.Promise", align 8
  %0 = call token @llvm.coro.id(i32 0, ptr %__promise, ptr null, ptr null)
  %1 = call ptr @llvm.coro.begin(token %0, ptr null)
  %2 = call token @llvm.coro.save(ptr null)
  ret void
}

; CHECK: define void @test_coro_function()

; Check that frame debug info is generated
; CHECK: ![[FRAME_TYPE:[0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "{{.*}}.coro_frame_ty"

; Key validation: Check that nested structs have the correct scope hierarchy
; 1. Promise should be scoped to the frame
; CHECK: ![[PROMISE:[0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "class_Promise", scope: ![[FRAME_TYPE]]

; 2. Members of Promise should be scoped to Promise (check this before Outer since it comes first in output)
; CHECK: !DIDerivedType(tag: DW_TAG_member, name: "struct_Outer", scope: ![[PROMISE]]

; 3. Outer should be scoped to Promise (not the frame!)
; CHECK: ![[OUTER:[0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "struct_Outer", scope: ![[PROMISE]]

; 4. First Outer member should be scoped to Outer
; CHECK: !DIDerivedType(tag: DW_TAG_member, name: "struct_Inner", scope: ![[OUTER]]

; 5. Inner should be scoped to Outer (proper nesting)
; CHECK: ![[INNER:[0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "struct_Inner", scope: ![[OUTER]]

; 6. Members of Inner should be scoped to Inner
; CHECK: !DIDerivedType(tag: DW_TAG_member, name: "__int_32", scope: ![[INNER]]
; CHECK: !DIDerivedType(tag: DW_TAG_member, name: "PointerType", scope: ![[INNER]]

; 7. Second Outer member comes after Inner (due to output order)
; CHECK: !DIDerivedType(tag: DW_TAG_member, name: "__int_64", scope: ![[OUTER]]

declare token @llvm.coro.id(i32, ptr readnone, ptr readonly, ptr)
declare ptr @llvm.coro.begin(token, ptr writeonly)
declare token @llvm.coro.save(ptr)

!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!9}

!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
!1 = !DIFile(filename: "test.cpp", directory: ".")
!9 = !{i32 2, !"Debug Info Version", i32 3}
!10 = distinct !DISubprogram(name: "test_coro_function", scope: !1, file: !1, line: 1, type: !11, spFlags: DISPFlagDefinition, unit: !0)
!11 = !DISubroutineType(types: !12)
!12 = !{null}