xref: /llvm-project/llvm/test/Transforms/Coroutines/coro-debug-frame-variable-inlined.ll (revision 910292c3ac2ebe43cdbc90223c6c9702128316db)
1; RUN: opt < %s -passes='module(coro-early),cgscc(inline,coro-split)' -S | FileCheck %s
2; RUN: opt --try-experimental-debuginfo-iterators < %s -passes='module(coro-early),cgscc(inline,coro-split)' -S | FileCheck %s
3
4; Simplified version from pr#75104.
5; Make sure we do not update debug location for hosited dbg.declare intrinsics when optimizing coro frame.
6
7; CHECK-NOT: mismatched subprogram between llvm.dbg.declare variable and !dbg attachment
8
9%"struct.std::coroutine_handle" = type { i8 }
10
11define void @_Z1fv() presplitcoroutine {
12entry:
13  %0 = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
14  %1 = call ptr @llvm.coro.begin(token %0, ptr null), !dbg !10
15  br label %for.cond
16
17for.cond:                                         ; preds = %for.cond, %entry
18  call void @_ZN1BD1Ev()
19  %2 = call token @llvm.coro.save(ptr null)
20  %3 = call i8 @llvm.coro.suspend(token none, i1 false)
21  br label %for.cond
22}
23
24declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr)
25declare ptr @llvm.coro.begin(token, ptr writeonly)
26declare void @llvm.dbg.declare(metadata, metadata, metadata)
27declare token @llvm.coro.save(ptr)
28declare i8 @llvm.coro.suspend(token, i1)
29
30define void @_ZN1BD1Ev() {
31entry:
32  %b11 = alloca [0 x [0 x %"struct.std::coroutine_handle"]], i32 0, align 1
33  call void @llvm.dbg.declare(metadata ptr %b11, metadata !13, metadata !DIExpression()), !dbg !21
34  %call = call i1 @_ZNSt16coroutine_handleIvEcvbEv(ptr %b11), !dbg !21
35  ret void
36}
37
38declare i1 @_ZNSt16coroutine_handleIvEcvbEv(ptr)
39
40!llvm.dbg.cu = !{!0}
41!llvm.module.flags = !{!9}
42
43!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 18.0.0git", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: !2, splitDebugInlining: false, nameTableKind: None)
44!1 = !DIFile(filename: "<stdin>", directory: "")
45!2 = !{!3}
46!3 = !DIGlobalVariableExpression(var: !4, expr: !DIExpression())
47!4 = distinct !DIGlobalVariable(name: "a", scope: !0, file: !5, line: 17, type: !6, isLocal: false, isDefinition: true)
48!5 = !DIFile(filename: "bad.cpp", directory: "")
49!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "coroutine_handle<void>", scope: !7, file: !5, line: 2, size: 8, flags: DIFlagTypePassByValue, elements: !8, templateParams: !8, identifier: "_ZTSSt16coroutine_handleIvE")
50!7 = !DINamespace(name: "std", scope: null)
51!8 = !{}
52!9 = !{i32 2, !"Debug Info Version", i32 3}
53!10 = !DILocation(line: 31, column: 7, scope: !11)
54!11 = distinct !DISubprogram(name: "f", linkageName: "_Z1fv", scope: !5, file: !5, line: 31, type: !12, scopeLine: 31, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8)
55!12 = distinct !DISubroutineType(types: !8)
56!13 = !DILocalVariable(name: "b", scope: !14, file: !5, line: 27, type: !6)
57!14 = distinct !DILexicalBlock(scope: !15, file: !5, line: 27, column: 14)
58!15 = distinct !DILexicalBlock(scope: !16, file: !5, line: 26, column: 8)
59!16 = distinct !DISubprogram(name: "~B", linkageName: "_ZN1BD2Ev", scope: !17, file: !5, line: 26, type: !18, scopeLine: 26, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, declaration: !20, retainedNodes: !8)
60!17 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "B", file: !5, line: 18, size: 8, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !8, identifier: "_ZTS1B")
61!18 = !DISubroutineType(types: !19)
62!19 = !{null}
63!20 = !DISubprogram(name: "~B", scope: !17, file: !5, line: 26, type: !18, scopeLine: 26, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)
64!21 = !DILocation(line: 27, column: 14, scope: !14)
65