[TTI] getTypeBasedIntrinsicInstrCost - add basic handling for strided load/store...
[llvm-project.git] / llvm / test / Transforms / Coroutines / coro-debug-O2.ll
blob588f47959cc5d50f5e58485bcebb9df0dd48a8d1
1 ; RUN: opt < %s -passes='module(coro-early),cgscc(coro-split<reuse-storage>),function(sroa)' -S | FileCheck %s
2 ; RUN: opt --try-experimental-debuginfo-iterators < %s -passes='module(coro-early),cgscc(coro-split<reuse-storage>),function(sroa)' -S | FileCheck %s
4 ; Checks the dbg informations about promise and coroutine frames under O2.
6 ; CHECK-LABEL: define internal fastcc void @f.resume({{.*}})
7 ; CHECK:       entry.resume:
8 ; CHECK:        #dbg_value(ptr poison, ![[PROMISEVAR_RESUME:[0-9]+]], !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 16
9 ; CHECK:        #dbg_value(ptr %begin, ![[CORO_FRAME:[0-9]+]], !DIExpression(DW_OP_deref)
11 ; CHECK: ![[CORO_FRAME]] = !DILocalVariable(name: "__coro_frame"
12 ; CHECK: ![[PROMISEVAR_RESUME]] = !DILocalVariable(name: "__promise"
13 %promise_type = type { i32, i32, double }
15 define void @f() presplitcoroutine !dbg !8  {
16 entry:
17     %__promise = alloca %promise_type, align 8
18     %id = call token @llvm.coro.id(i32 16, ptr %__promise, ptr null, ptr null)
19     %alloc = call i1 @llvm.coro.alloc(token %id)
20     br i1 %alloc, label %coro.alloc, label %coro.init
22 coro.alloc:                                       ; preds = %entry
23     %size = call i64 @llvm.coro.size.i64()
24     %memory = call ptr @new(i64 %size)
25     br label %coro.init
27 coro.init:                                        ; preds = %coro.alloc, %entry
28     %phi.entry.alloc = phi ptr [ null, %entry ], [ %memory, %coro.alloc ]
29     %begin = call ptr @llvm.coro.begin(token %id, ptr %phi.entry.alloc)
30     call void @llvm.dbg.declare(metadata ptr %__promise, metadata !6, metadata !DIExpression()), !dbg !18
31     store i32 1, ptr %__promise, align 8
32     %j.i = getelementptr inbounds %promise_type, ptr %__promise, i64 0, i32 1
33     store i32 2, ptr %j.i, align 4
34     %k.i = getelementptr inbounds %promise_type, ptr %__promise, i64 0, i32 2
35     store double 3.000000e+00, ptr %k.i, align 8
36     %ready = call i1 @await_ready()
37     br i1 %ready, label %init.ready, label %init.suspend
39 init.suspend:                                     ; preds = %coro.init
40     %save = call token @llvm.coro.save(ptr null)
41     call void @await_suspend()
42     %suspend = call i8 @llvm.coro.suspend(token %save, i1 false)
43     switch i8 %suspend, label %coro.ret [
44         i8 0, label %init.ready
45         i8 1, label %init.cleanup
46     ]
48 init.cleanup:                                     ; preds = %init.suspend
49     br label %cleanup
51 init.ready:                                       ; preds = %init.suspend, %coro.init
52     call void @await_resume()
53     %ready.again = call zeroext i1 @await_ready()
54     br i1 %ready.again, label %await.ready, label %await.suspend
56 await.suspend:                                    ; preds = %init.ready
57     %save.again = call token @llvm.coro.save(ptr null)
58     %from.address = call ptr @from_address(ptr %begin)
59     call void @await_suspend()
60     %suspend.again = call i8 @llvm.coro.suspend(token %save.again, i1 false)
61     switch i8 %suspend.again, label %coro.ret [
62         i8 0, label %await.ready
63         i8 1, label %await.cleanup
64     ]
66 await.cleanup:                                    ; preds = %await.suspend
67     br label %cleanup
69 await.ready:                                      ; preds = %await.suspend, %init.ready
70     call void @await_resume()
71     call void @return_void()
72     br label %coro.final
74 coro.final:                                       ; preds = %await.ready
75     call void @final_suspend()
76     %coro.final.await_ready = call i1 @await_ready()
77     br i1 %coro.final.await_ready, label %final.ready, label %final.suspend
79 final.suspend:                                    ; preds = %coro.final
80     %final.suspend.coro.save = call token @llvm.coro.save(ptr null)
81     %final.suspend.from_address = call ptr @from_address(ptr %begin)
82     call void @await_suspend()
83     %final.suspend.coro.suspend = call i8 @llvm.coro.suspend(token %final.suspend.coro.save, i1 true)
84     switch i8 %final.suspend.coro.suspend, label %coro.ret [
85         i8 0, label %final.ready
86         i8 1, label %final.cleanup
87     ]
89 final.cleanup:                                    ; preds = %final.suspend
90     br label %cleanup
92 final.ready:                                      ; preds = %final.suspend, %coro.final
93     call void @await_resume()
94     br label %cleanup
96 cleanup:                                          ; preds = %final.ready, %final.cleanup, %await.cleanup, %init.cleanup
97     %cleanup.dest.slot.0 = phi i32 [ 0, %final.ready ], [ 2, %final.cleanup ], [ 2, %await.cleanup ], [ 2, %init.cleanup ]
98     %free.memory = call ptr @llvm.coro.free(token %id, ptr %begin)
99     %free = icmp ne ptr %free.memory, null
100     br i1 %free, label %coro.free, label %after.coro.free
102 coro.free:                                        ; preds = %cleanup
103     call void @delete(ptr %free.memory)
104     br label %after.coro.free
106 after.coro.free:                                  ; preds = %coro.free, %cleanup
107     switch i32 %cleanup.dest.slot.0, label %unreachable [
108         i32 0, label %cleanup.cont
109         i32 2, label %coro.ret
110     ]
112 cleanup.cont:                                     ; preds = %after.coro.free
113     br label %coro.ret
115 coro.ret:                                         ; preds = %cleanup.cont, %after.coro.free, %final.suspend, %await.suspend, %init.suspend
116     %end = call i1 @llvm.coro.end(ptr null, i1 false, token none)
117     ret void
119 unreachable:                                      ; preds = %after.coro.free
120     unreachable
124 declare void @llvm.dbg.declare(metadata, metadata, metadata)
125 declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr)
126 declare i1 @llvm.coro.alloc(token)
127 declare i64 @llvm.coro.size.i64()
128 declare token @llvm.coro.save(ptr)
129 declare ptr @llvm.coro.begin(token, ptr writeonly)
130 declare i8 @llvm.coro.suspend(token, i1)
131 declare ptr @llvm.coro.free(token, ptr nocapture readonly)
132 declare i1 @llvm.coro.end(ptr, i1, token)
134 declare ptr @new(i64)
135 declare void @delete(ptr)
136 declare i1 @await_ready()
137 declare void @await_suspend()
138 declare void @await_resume()
139 declare void @print(i32)
140 declare ptr @from_address(ptr)
141 declare void @return_void()
142 declare void @final_suspend()
144 !llvm.dbg.cu = !{!0}
145 !llvm.linker.options = !{}
146 !llvm.module.flags = !{!3, !4}
147 !llvm.ident = !{!5}
149 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 11.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2, splitDebugInlining: false, nameTableKind: None)
150 !1 = !DIFile(filename: "coro-debug.cpp", directory: ".")
151 !2 = !{}
152 !3 = !{i32 7, !"Dwarf Version", i32 4}
153 !4 = !{i32 2, !"Debug Info Version", i32 3}
154 !5 = !{!"clang version 11.0.0"}
155 !6 = !DILocalVariable(name: "__promise", scope: !7, file: !1, line: 24, type: !10)
156 !7 = distinct !DILexicalBlock(scope: !8, file: !1, line: 23, column: 12)
157 !8 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !8, file: !1, line: 23, type: !9, scopeLine: 23, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
158 !9 = !DISubroutineType(types: !2)
159 !10 = !DIDerivedType(tag: DW_TAG_typedef, name: "promise_type", scope: !8, file: !1, line: 15, baseType: !11)
160 !11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "promise_type", scope: !8, file: !1, line: 10, size: 128, flags: DIFlagTypePassByValue | DIFlagNonTrivial, elements: !12, identifier: "_ZTSN4coro12promise_typeE")
161 !12 = !{!13, !14, !15}
162 !13 = !DIDerivedType(tag: DW_TAG_member, name: "i", scope: !8, file: !1, line: 10, baseType: !16, size: 32)
163 !14 = !DIDerivedType(tag: DW_TAG_member, name: "j", scope: !8, file: !1, line: 10, baseType: !16, size: 32, offset: 32)
164 !15 = !DIDerivedType(tag: DW_TAG_member, name: "k", scope: !8, file: !1, line: 10, baseType: !17, size: 64, offset: 64)
165 !16 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
166 !17 = !DIBasicType(name: "double", size: 64, encoding: DW_ATE_float)
167 !18 = !DILocation(line: 0, scope: !7)