1; Tests whether resume function would remain dbg.value infomation. 2; RUN: opt < %s -passes='module(coro-early),cgscc(coro-split,coro-split)' -S | FileCheck %s 3; RUN: opt --try-experimental-debuginfo-iterators < %s -passes='module(coro-early),cgscc(coro-split,coro-split)' -S | FileCheck %s 4; 5; This file is based on coro-debug-frame-variable.ll. 6; CHECK-LABEL: define void @f( 7; CHECK: %[[frame:.*]] = call {{.*}} @llvm.coro.begin 8; CHECK: #dbg_value(ptr %[[frame]] 9; CHECK-SAME: !DIExpression(DW_OP_plus_uconst, [[OffsetX:[0-9]*]]), 10; ^ No deref at the end, as this variable ("x") is an array; 11; its value is its address. The entire array is in the frame. 12; CHECK: #dbg_assign(ptr %[[frame]] 13; CHECK-SAME: !DIExpression(DW_OP_plus_uconst, [[OffsetX]]) 14;; FIXME: Should we be updating the addresses on assigns here as well? 15; CHECK-SAME: , ptr %[[frame]], !DIExpression(), 16 17; CHECK: #dbg_value(ptr %[[frame]] 18; CHECK-SAME: !DIExpression(DW_OP_plus_uconst, [[OffsetSpill:[0-9]*]], DW_OP_deref), 19; CHECK: #dbg_value(ptr %[[frame]] 20; CHECK-SAME: !DIExpression(DW_OP_plus_uconst, [[OffsetI:[0-9]*]], DW_OP_deref), 21; CHECK: #dbg_value(ptr %[[frame]] 22; CHECK-SAME: !DIExpression(DW_OP_plus_uconst, [[OffsetJ:[0-9]*]], DW_OP_deref), 23 24; CHECK-LABEL: void @f.resume( 25; CHECK-SAME: ptr {{.*}} %[[frame:.*]]) 26; CHECK-SAME: !dbg ![[RESUME_FN_DBG_NUM:[0-9]+]] 27; CHECK: %[[frame_alloca:.*]] = alloca ptr 28; CHECK-NEXT: #dbg_declare(ptr %begin.debug, ![[FRAME_DI_NUM:[0-9]+]], 29; CHECK-NEXT: store ptr %[[frame]], ptr %[[frame_alloca]] 30; CHECK: init.ready: 31; CHECK: #dbg_value(ptr %[[frame_alloca]], ![[XVAR_RESUME:[0-9]+]], 32; CHECK-SAME: !DIExpression(DW_OP_deref, DW_OP_plus_uconst, [[OffsetX]]) 33; CHECK: await.ready: 34; CHECK: #dbg_value(ptr %[[frame_alloca]], ![[SPILL_RESUME:[0-9]+]] 35; CHECK-SAME: !DIExpression(DW_OP_deref, DW_OP_plus_uconst, [[OffsetSpill]], DW_OP_deref) 36; CHECK: #dbg_value(ptr %[[frame_alloca]], ![[IVAR_RESUME:[0-9]+]], 37; CHECK-SAME: !DIExpression(DW_OP_deref, DW_OP_plus_uconst, [[OffsetI]], DW_OP_deref) 38; CHECK: #dbg_value(ptr %[[frame_alloca]], ![[JVAR_RESUME:[0-9]+]], 39; CHECK-SAME: !DIExpression(DW_OP_deref, DW_OP_plus_uconst, [[OffsetJ]], DW_OP_deref) 40; 41; CHECK: ![[RESUME_FN_DBG_NUM]] = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov" 42; CHECK: ![[FRAME_DI_NUM]] = !DILocalVariable(name: "__coro_frame" 43; CHECK: ![[IVAR_RESUME]] = !DILocalVariable(name: "i" 44; CHECK: ![[XVAR_RESUME]] = !DILocalVariable(name: "x" 45; CHECK: ![[JVAR_RESUME]] = !DILocalVariable(name: "j" 46; CHECK: ![[SPILL_RESUME]] = !DILocalVariable(name: "produced" 47 48declare void @consume(i32) 49 50define void @f(i32 %i, i32 %j) presplitcoroutine !dbg !8 { 51entry: 52 %__promise = alloca i8, align 8 53 %x = alloca [10 x i32], align 16 54 %produced = call i32 @value_producer() 55 %id = call token @llvm.coro.id(i32 16, ptr %__promise, ptr null, ptr null) 56 %alloc = call i1 @llvm.coro.alloc(token %id) 57 br i1 %alloc, label %coro.alloc, label %coro.init 58 59coro.alloc: ; preds = %entry 60 %size = call i64 @llvm.coro.size.i64() 61 %memory = call ptr @new(i64 %size) 62 br label %coro.init 63 64coro.init: ; preds = %coro.alloc, %entry 65 %phi.entry.alloc = phi ptr [ null, %entry ], [ %memory, %coro.alloc ] 66 %begin = call ptr @llvm.coro.begin(token %id, ptr %phi.entry.alloc) 67 %ready = call i1 @await_ready() 68 br i1 %ready, label %init.ready, label %init.suspend 69 70init.suspend: ; preds = %coro.init 71 %save = call token @llvm.coro.save(ptr null) 72 call void @await_suspend() 73 %suspend = call i8 @llvm.coro.suspend(token %save, i1 false) 74 switch i8 %suspend, label %coro.ret [ 75 i8 0, label %init.ready 76 i8 1, label %init.cleanup 77 ] 78 79init.cleanup: ; preds = %init.suspend 80 br label %cleanup 81 82init.ready: ; preds = %init.suspend, %coro.init 83 call void @await_resume() 84 call void @llvm.dbg.value(metadata i32 0, metadata !6, metadata !DIExpression()), !dbg !11 85 %i.init.ready.inc = add nsw i32 0, 1 86 call void @llvm.dbg.value(metadata i32 %i.init.ready.inc, metadata !6, metadata !DIExpression()), !dbg !11 87 call void @llvm.dbg.value(metadata ptr %x, metadata !12, metadata !DIExpression()), !dbg !17 88 call void @llvm.dbg.assign(metadata ptr %x, metadata !12, metadata !DIExpression(), metadata !30, metadata ptr %x, metadata !DIExpression()), !dbg !17 89 call void @llvm.memset.p0.i64(ptr align 16 %x, i8 0, i64 40, i1 false), !dbg !17 90 call void @print(i32 %i.init.ready.inc) 91 %ready.again = call zeroext i1 @await_ready() 92 br i1 %ready.again, label %await.ready, label %await.suspend 93 94await.suspend: ; preds = %init.ready 95 %save.again = call token @llvm.coro.save(ptr null) 96 %from.address = call ptr @from_address(ptr %begin) 97 call void @await_suspend() 98 %suspend.again = call i8 @llvm.coro.suspend(token %save.again, i1 false) 99 switch i8 %suspend.again, label %coro.ret [ 100 i8 0, label %await.ready 101 i8 1, label %await.cleanup 102 ] 103 104await.cleanup: ; preds = %await.suspend 105 br label %cleanup 106 107await.ready: ; preds = %await.suspend, %init.ready 108 call void @await_resume() 109 call void @llvm.dbg.value(metadata i32 0, metadata !18, metadata !DIExpression()), !dbg !11 110 store i32 1, ptr %x, align 16, !dbg !20 111 %arrayidx1 = getelementptr inbounds [10 x i32], ptr %x, i64 0, i64 1, !dbg !21 112 store i32 2, ptr %arrayidx1, align 4, !dbg !22 113 %i.await.ready.inc = add nsw i32 %i.init.ready.inc, 1 114 call void @consume(i32 %produced) 115 call void @consume(i32 %i) 116 call void @consume(i32 %j) 117 call void @llvm.dbg.value(metadata i32 %produced, metadata !23, metadata !DIExpression()), !dbg !11 118 call void @llvm.dbg.value(metadata i32 %i, metadata !6, metadata !DIExpression()), !dbg !11 119 call void @llvm.dbg.value(metadata i32 %j, metadata !18, metadata !DIExpression()), !dbg !11 120 call void @print(i32 %i.await.ready.inc) 121 call void @return_void() 122 br label %coro.final 123 124coro.final: ; preds = %await.ready 125 call void @final_suspend() 126 %coro.final.await_ready = call i1 @await_ready() 127 br i1 %coro.final.await_ready, label %final.ready, label %final.suspend 128 129final.suspend: ; preds = %coro.final 130 %final.suspend.coro.save = call token @llvm.coro.save(ptr null) 131 %final.suspend.from_address = call ptr @from_address(ptr %begin) 132 call void @await_suspend() 133 %final.suspend.coro.suspend = call i8 @llvm.coro.suspend(token %final.suspend.coro.save, i1 true) 134 switch i8 %final.suspend.coro.suspend, label %coro.ret [ 135 i8 0, label %final.ready 136 i8 1, label %final.cleanup 137 ] 138 139final.cleanup: ; preds = %final.suspend 140 br label %cleanup 141 142final.ready: ; preds = %final.suspend, %coro.final 143 call void @await_resume() 144 br label %cleanup 145 146cleanup: ; preds = %final.ready, %final.cleanup, %await.cleanup, %init.cleanup 147 %cleanup.dest.slot.0 = phi i32 [ 0, %final.ready ], [ 2, %final.cleanup ], [ 2, %await.cleanup ], [ 2, %init.cleanup ] 148 %free.memory = call ptr @llvm.coro.free(token %id, ptr %begin) 149 %free = icmp ne ptr %free.memory, null 150 br i1 %free, label %coro.free, label %after.coro.free 151 152coro.free: ; preds = %cleanup 153 call void @delete(ptr %free.memory) 154 br label %after.coro.free 155 156after.coro.free: ; preds = %coro.free, %cleanup 157 switch i32 %cleanup.dest.slot.0, label %unreachable [ 158 i32 0, label %cleanup.cont 159 i32 2, label %coro.ret 160 ] 161 162cleanup.cont: ; preds = %after.coro.free 163 br label %coro.ret 164 165coro.ret: ; preds = %cleanup.cont, %after.coro.free, %final.suspend, %await.suspend, %init.suspend 166 %end = call i1 @llvm.coro.end(ptr null, i1 false, token none) 167 ret void 168 169unreachable: ; preds = %after.coro.free 170 unreachable 171} 172 173; Function Attrs: nofree nosync nounwind readnone speculatable willreturn 174declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 175 176; Function Attrs: argmemonly nounwind readonly 177declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr) #1 178 179; Function Attrs: nounwind 180declare i1 @llvm.coro.alloc(token) #2 181 182; Function Attrs: nounwind readnone 183declare i64 @llvm.coro.size.i64() #3 184 185; Function Attrs: nounwind 186declare token @llvm.coro.save(ptr) #2 187 188; Function Attrs: nounwind 189declare ptr @llvm.coro.begin(token, ptr writeonly) #2 190 191; Function Attrs: nounwind 192declare i8 @llvm.coro.suspend(token, i1) #2 193 194; Function Attrs: argmemonly nounwind readonly 195declare ptr @llvm.coro.free(token, ptr nocapture readonly) #1 196 197; Function Attrs: nounwind 198declare i1 @llvm.coro.end(ptr, i1, token) #2 199 200declare ptr @new(i64) 201 202declare void @delete(ptr) 203 204declare i1 @await_ready() 205 206declare void @await_suspend() 207 208declare void @await_resume() 209 210declare void @print(i32) 211 212declare ptr @from_address(ptr) 213 214declare void @return_void() 215 216declare void @final_suspend() 217 218declare i32 @value_producer() 219 220; Function Attrs: argmemonly nofree nosync nounwind willreturn writeonly 221declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4 222 223; Function Attrs: nofree nosync nounwind readnone speculatable willreturn 224declare void @llvm.dbg.value(metadata, metadata, metadata) #0 225 226attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } 227attributes #1 = { argmemonly nounwind readonly } 228attributes #2 = { nounwind } 229attributes #3 = { nounwind readnone } 230attributes #4 = { argmemonly nofree nosync nounwind willreturn writeonly } 231 232!llvm.dbg.cu = !{!0} 233!llvm.linker.options = !{} 234!llvm.module.flags = !{!3, !4} 235!llvm.ident = !{!5} 236 237!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) 238!1 = !DIFile(filename: "repro.cpp", directory: ".") 239!2 = !{} 240!3 = !{i32 7, !"Dwarf Version", i32 4} 241!4 = !{i32 2, !"Debug Info Version", i32 3} 242!5 = !{!"clang version 11.0.0"} 243!6 = !DILocalVariable(name: "i", scope: !7, file: !1, line: 24, type: !10) 244!7 = distinct !DILexicalBlock(scope: !8, file: !1, line: 23, column: 12) 245!8 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 23, type: !9, scopeLine: 23, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) 246!9 = !DISubroutineType(types: !2) 247!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 248!11 = !DILocation(line: 0, scope: !7) 249!12 = !DILocalVariable(name: "x", scope: !13, file: !1, line: 34, type: !14) 250!13 = distinct !DILexicalBlock(scope: !8, file: !1, line: 23, column: 12) 251!14 = !DICompositeType(tag: DW_TAG_array_type, baseType: !10, size: 320, elements: !15) 252!15 = !{!16} 253!16 = !DISubrange(count: 10) 254!17 = !DILocation(line: 24, column: 7, scope: !7) 255!18 = !DILocalVariable(name: "j", scope: !7, file: !1, line: 32, type: !10) 256!19 = !DILocation(line: 42, column: 3, scope: !7) 257!20 = !DILocation(line: 42, column: 8, scope: !7) 258!21 = !DILocation(line: 43, column: 3, scope: !7) 259!22 = !DILocation(line: 43, column: 8, scope: !7) 260!23 = !DILocalVariable(name: "produced", scope: !7, file: !1, line:24, type: !10) 261!30 = distinct !DIAssignID()