173 lines · plain
1; RUN: opt < %s -passes='module(coro-early),cgscc(coro-split<reuse-storage>),function(sroa)' -S | FileCheck %s2 3; Checks the dbg informations about promise and coroutine frames under O2.4 5; CHECK-LABEL: define internal fastcc void @f.resume({{.*}})6; CHECK: entry.resume:7; CHECK: #dbg_value(ptr poison, ![[PROMISEVAR_RESUME:[0-9]+]], !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 168; CHECK: #dbg_value(ptr %begin, ![[CORO_FRAME:[0-9]+]], !DIExpression(DW_OP_deref)9;10; CHECK: ![[CORO_FRAME]] = !DILocalVariable(name: "__coro_frame"11; CHECK: ![[PROMISEVAR_RESUME]] = !DILocalVariable(name: "__promise"12%promise_type = type { i32, i32, double }13 14define void @f() presplitcoroutine !dbg !8 {15entry:16 %__promise = alloca %promise_type, align 817 %id = call token @llvm.coro.id(i32 16, ptr %__promise, ptr null, ptr null)18 %alloc = call i1 @llvm.coro.alloc(token %id)19 br i1 %alloc, label %coro.alloc, label %coro.init20 21coro.alloc: ; preds = %entry22 %size = call i64 @llvm.coro.size.i64()23 %memory = call ptr @new(i64 %size)24 br label %coro.init25 26coro.init: ; preds = %coro.alloc, %entry27 %phi.entry.alloc = phi ptr [ null, %entry ], [ %memory, %coro.alloc ]28 %begin = call ptr @llvm.coro.begin(token %id, ptr %phi.entry.alloc)29 call void @llvm.dbg.declare(metadata ptr %__promise, metadata !6, metadata !DIExpression()), !dbg !1830 store i32 1, ptr %__promise, align 831 %j.i = getelementptr inbounds %promise_type, ptr %__promise, i64 0, i32 132 store i32 2, ptr %j.i, align 433 %k.i = getelementptr inbounds %promise_type, ptr %__promise, i64 0, i32 234 store double 3.000000e+00, ptr %k.i, align 835 %ready = call i1 @await_ready()36 br i1 %ready, label %init.ready, label %init.suspend37 38init.suspend: ; preds = %coro.init39 %save = call token @llvm.coro.save(ptr null)40 call void @await_suspend()41 %suspend = call i8 @llvm.coro.suspend(token %save, i1 false)42 switch i8 %suspend, label %coro.ret [43 i8 0, label %init.ready44 i8 1, label %init.cleanup45 ]46 47init.cleanup: ; preds = %init.suspend48 br label %cleanup49 50init.ready: ; preds = %init.suspend, %coro.init51 call void @await_resume()52 %ready.again = call zeroext i1 @await_ready()53 br i1 %ready.again, label %await.ready, label %await.suspend54 55await.suspend: ; preds = %init.ready56 %save.again = call token @llvm.coro.save(ptr null)57 %from.address = call ptr @from_address(ptr %begin)58 call void @await_suspend()59 %suspend.again = call i8 @llvm.coro.suspend(token %save.again, i1 false)60 switch i8 %suspend.again, label %coro.ret [61 i8 0, label %await.ready62 i8 1, label %await.cleanup63 ]64 65await.cleanup: ; preds = %await.suspend66 br label %cleanup67 68await.ready: ; preds = %await.suspend, %init.ready69 call void @await_resume()70 call void @return_void()71 br label %coro.final72 73coro.final: ; preds = %await.ready74 call void @final_suspend()75 %coro.final.await_ready = call i1 @await_ready()76 br i1 %coro.final.await_ready, label %final.ready, label %final.suspend77 78final.suspend: ; preds = %coro.final79 %final.suspend.coro.save = call token @llvm.coro.save(ptr null)80 %final.suspend.from_address = call ptr @from_address(ptr %begin)81 call void @await_suspend()82 %final.suspend.coro.suspend = call i8 @llvm.coro.suspend(token %final.suspend.coro.save, i1 true)83 switch i8 %final.suspend.coro.suspend, label %coro.ret [84 i8 0, label %final.ready85 i8 1, label %final.cleanup86 ]87 88final.cleanup: ; preds = %final.suspend89 br label %cleanup90 91final.ready: ; preds = %final.suspend, %coro.final92 call void @await_resume()93 br label %cleanup94 95cleanup: ; preds = %final.ready, %final.cleanup, %await.cleanup, %init.cleanup96 %cleanup.dest.slot.0 = phi i32 [ 0, %final.ready ], [ 2, %final.cleanup ], [ 2, %await.cleanup ], [ 2, %init.cleanup ]97 %free.memory = call ptr @llvm.coro.free(token %id, ptr %begin)98 %free = icmp ne ptr %free.memory, null99 br i1 %free, label %coro.free, label %after.coro.free100 101coro.free: ; preds = %cleanup102 call void @delete(ptr %free.memory)103 br label %after.coro.free104 105after.coro.free: ; preds = %coro.free, %cleanup106 switch i32 %cleanup.dest.slot.0, label %unreachable [107 i32 0, label %cleanup.cont108 i32 2, label %coro.ret109 ]110 111cleanup.cont: ; preds = %after.coro.free112 br label %coro.ret113 114coro.ret: ; preds = %cleanup.cont, %after.coro.free, %final.suspend, %await.suspend, %init.suspend115 call void @llvm.coro.end(ptr null, i1 false, token none)116 ret void117 118unreachable: ; preds = %after.coro.free119 unreachable120 121}122 123declare void @llvm.dbg.declare(metadata, metadata, metadata)124declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr)125declare i1 @llvm.coro.alloc(token)126declare i64 @llvm.coro.size.i64()127declare token @llvm.coro.save(ptr)128declare ptr @llvm.coro.begin(token, ptr writeonly)129declare i8 @llvm.coro.suspend(token, i1)130declare ptr @llvm.coro.free(token, ptr nocapture readonly)131declare void @llvm.coro.end(ptr, i1, token)132 133declare ptr @new(i64)134declare void @delete(ptr)135declare i1 @await_ready()136declare void @await_suspend()137declare void @await_resume()138declare void @print(i32)139declare ptr @from_address(ptr)140declare void @return_void()141declare void @final_suspend()142 143!llvm.dbg.cu = !{!0}144!llvm.linker.options = !{}145!llvm.module.flags = !{!3, !4}146!llvm.ident = !{!5}147 148!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)149!1 = !DIFile(filename: "coro-debug.cpp", directory: ".")150!2 = !{}151!3 = !{i32 7, !"Dwarf Version", i32 4}152!4 = !{i32 2, !"Debug Info Version", i32 3}153!5 = !{!"clang version 11.0.0"}154!6 = !DILocalVariable(name: "__promise", scope: !7, file: !1, line: 24, type: !10)155!7 = distinct !DILexicalBlock(scope: !8, file: !1, line: 23, column: 12)156!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)157!9 = !DISubroutineType(types: !2)158!10 = !DIDerivedType(tag: DW_TAG_typedef, name: "promise_type", scope: !8, file: !1, line: 15, baseType: !11)159!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")160!12 = !{!13, !14, !15}161!13 = !DIDerivedType(tag: DW_TAG_member, name: "i", scope: !8, file: !1, line: 10, baseType: !16, size: 32)162!14 = !DIDerivedType(tag: DW_TAG_member, name: "j", scope: !8, file: !1, line: 10, baseType: !16, size: 32, offset: 32)163!15 = !DIDerivedType(tag: DW_TAG_member, name: "k", scope: !8, file: !1, line: 10, baseType: !17, size: 64, offset: 64)164!16 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)165!17 = !DIBasicType(name: "double", size: 64, encoding: DW_ATE_float)166!18 = !DILocation(line: 0, scope: !7)167 168 169 170 171 172 173