brintos

brintos / llvm-project-archived public Read only

0
0
Text · 10.1 KiB · 00138c0 Raw
175 lines · plain
1; RUN: opt -mtriple='arm64-' %s -S -passes='module(coro-early),cgscc(coro-split,simplifycfg)' -o - | FileCheck %s2; RUN: opt -mtriple='x86_64' %s -S -passes='module(coro-early),cgscc(coro-split,simplifycfg)' -o - | FileCheck %s3; RUN: opt -mtriple='i386-' %s -S -passes='module(coro-early),cgscc(coro-split,simplifycfg)' -o - | FileCheck %s --check-prefix=NOENTRY4; RUN: opt -mtriple='armv7-' %s -S -passes='module(coro-early),cgscc(coro-split,simplifycfg)' -o - | FileCheck %s --check-prefix=NOENTRY5 6; NOENTRY-NOT: OP_llvm_entry_value7 8target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"9 10; This coroutine has one split point and two variables defined by:11;   %var_with_dbg_value,   which has multiple dbg.value intrinsics associated with12;                          it, one per split point.13;   %var_with_dbg_declare, which has a single dbg.declare intrinsic associated14;                          with it at the coroutine entry.15; We check that, for each funclet, the debug intrinsics are propagated properly AND that16; an `entry_value` operation is created.17define swifttailcc void @coroutineA(ptr swiftasync %arg) !dbg !48 {18  %var_with_dbg_value = alloca ptr, align 819  %var_with_dbg_declare = alloca ptr, align 820  call void @llvm.dbg.declare(metadata ptr %var_with_dbg_declare, metadata !500, metadata !DIExpression()), !dbg !5421  call void @llvm.dbg.value(metadata ptr %var_with_dbg_value, metadata !50, metadata !DIExpression(DW_OP_deref)), !dbg !5422  %i2 = call token @llvm.coro.id.async(i32 16, i32 16, i32 0, ptr nonnull @coroutineATu)23  %i3 = call ptr @llvm.coro.begin(token %i2, ptr null)24; CHECK-LABEL: define {{.*}} @coroutineA(25; CHECK-SAME:    ptr swiftasync %[[frame_ptr:.*]])26; CHECK:      #dbg_declare(ptr %[[frame_ptr]], {{.*}} !DIExpression(27; CHECK-SAME:                   DW_OP_plus_uconst, 24)28; CHECK:      #dbg_value(ptr %[[frame_ptr]], {{.*}} !DIExpression(29; CHECK-SAME:                 DW_OP_plus_uconst, 16, DW_OP_deref)30; CHECK:      call {{.*}} @swift_task_switch31 32  %i7 = call ptr @llvm.coro.async.resume(), !dbg !5433  %i10 = call { ptr } (i32, ptr, ptr, ...) @llvm.coro.suspend.async.sl_p0s(i32 0, ptr %i7, ptr nonnull @__swift_async_resume_get_context, ptr nonnull @coroutineA.1, ptr %i7, i64 0, i64 0, ptr %arg), !dbg !5434  %i11 = extractvalue { ptr } %i10, 0, !dbg !5535  %i12 = call ptr @__swift_async_resume_get_context(ptr %i11), !dbg !5536  call void @dont_optimize(ptr %var_with_dbg_value, ptr %var_with_dbg_declare), !dbg !10037  call void @llvm.dbg.value(metadata ptr %var_with_dbg_value, metadata !50, metadata !DIExpression(DW_OP_deref)), !dbg !5438  %i17 = load i32, ptr getelementptr inbounds (<{i32, i32}>, ptr @coroutineBTu, i64 0, i32 1), align 8, !dbg !5439  call void @llvm.dbg.value(metadata !DIArgList(ptr %var_with_dbg_value, i32 %i17), metadata !501, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus, DW_OP_deref)), !dbg !5440  %i18 = zext i32 %i17 to i64, !dbg !5441  %i19 = call swiftcc ptr @swift_task_alloc(i64 %i18), !dbg !5442; CHECK-NOT: define43; CHECK-LABEL: define {{.*}} @coroutineATY0_(44; CHECK-SAME:    ptr swiftasync %[[frame_ptr:.*]]) !dbg ![[ATY0:[0-9]*]]45; CHECK:      #dbg_declare(ptr %[[frame_ptr]], {{.*}} !DIExpression(46; CHECK-SAME:                   DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 24)47; CHECK:      #dbg_value(ptr %[[frame_ptr]], {{.*}} !DIExpression(48; CHECK-SAME:                 DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_deref)49; CHECK:      #dbg_value(!DIArgList(ptr %[[frame_ptr]], i32 %{{.*}}), {{.*}} !DIExpression(50; CHECK-SAME:                 DW_OP_LLVM_arg, 0, DW_OP_plus_uconst, 16, DW_OP_LLVM_arg, 1, DW_OP_plus, DW_OP_deref)51; CHECK:      call {{.*}} @coroutineB52 53  %i23 = call ptr @llvm.coro.async.resume(), !dbg !5454  %i25 = getelementptr inbounds <{ ptr, ptr }>, ptr %i19, i64 0, i32 1, !dbg !5455  store ptr %i23, ptr %i25, align 8, !dbg !5456  %i27 = call { ptr } (i32, ptr, ptr, ...) @llvm.coro.suspend.async.sl_p0s(i32 0, ptr %i23, ptr nonnull @__swift_async_resume_project_context, ptr nonnull @coroutineA.0, ptr nonnull @coroutineB, ptr nonnull %i19), !dbg !5457  %i28 = extractvalue { ptr } %i27, 0, !dbg !5458  %i29 = call ptr @__swift_async_resume_project_context(ptr %i28), !dbg !5459  call swiftcc void @swift_task_dealloc(ptr nonnull %i19), !dbg !5460  call void @dont_optimize(ptr %var_with_dbg_value, ptr %var_with_dbg_declare)61  call void @llvm.dbg.value(metadata ptr %var_with_dbg_value, metadata !50, metadata !DIExpression(DW_OP_deref)), !dbg !5462; CHECK-NOT: define63; CHECK-LABEL: define {{.*}} @coroutineATQ1_(64; CHECK-SAME:    ptr swiftasync %[[frame_ptr:.*]])65; Note the extra level of indirection that shows up here!66; CHECK:      #dbg_declare(ptr %[[frame_ptr]], {{.*}} !DIExpression(67; CHECK-SAME:                   DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 24)68; CHECK:      #dbg_value(ptr %[[frame_ptr]], {{.*}} !DIExpression(69; CHECK-SAME:                 DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_deref)70; CHECK:      call {{.*}} @swift_task_switch71 72  %i31 = call ptr @llvm.coro.async.resume(), !dbg !5473  %i33 = call { ptr } (i32, ptr, ptr, ...) @llvm.coro.suspend.async.sl_p0s(i32 0, ptr %i31, ptr nonnull @__swift_async_resume_get_context, ptr nonnull @coroutineA.1, ptr %i31, i64 0, i64 0, ptr %i29), !dbg !5474  %i34 = extractvalue { ptr } %i33, 0, !dbg !5475  %i35 = call ptr @__swift_async_resume_get_context(ptr %i34), !dbg !5476  call void (ptr, i1, ...) @llvm.coro.end.async(ptr %i3, i1 false, ptr nonnull @coroutineA.0.1, ptr undef, ptr undef), !dbg !5477  unreachable, !dbg !5478; CHECK-NOT: define79; CHECK-LABEL: define {{.*}} @coroutineATY2_(80; CHECK-SAME:    ptr swiftasync %[[frame_ptr:.*]])81; CHECK:      #dbg_declare(ptr %[[frame_ptr]], {{.*}} !DIExpression(82; CHECK-SAME:                   DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 24)83}84 85; CHECK: ![[ATY0]] = {{.*}}DISubprogram(linkageName: "coroutineATY0_", {{.*}} scopeLine: 4286 87; Everything from here on is just support code for the coroutines.88 89@coroutineBTu = global <{i32, i32}> <{ i32 trunc (i64 sub (i64 ptrtoint (ptr @"coroutineB" to i64), i64 ptrtoint (ptr @"coroutineBTu" to i64)) to i32), i32 16 }>, align 890@coroutineATu = global <{i32, i32}> <{ i32 trunc (i64 sub (i64 ptrtoint (ptr @"coroutineA" to i64), i64 ptrtoint (ptr @"coroutineATu" to i64)) to i32), i32 16 }>, align 891 92define weak_odr hidden ptr @__swift_async_resume_get_context(ptr %arg) !dbg !64 {93  ret ptr %arg, !dbg !6594}95define hidden swifttailcc void @coroutineA.1(ptr %arg, i64 %arg1, i64 %arg2, ptr %arg3) !dbg !66 {96  musttail call swifttailcc void @swift_task_switch(ptr swiftasync %arg3, ptr %arg, i64 %arg1, i64 %arg2), !dbg !6797  ret void, !dbg !6798}99 100define weak_odr hidden ptr @__swift_async_resume_project_context(ptr %arg) !dbg !68 {101  %i1 = load ptr, ptr %arg, align 8, !dbg !69102  %i2 = call ptr @llvm.swift.async.context.addr(), !dbg !69103  store ptr %i1, ptr %i2, align 8, !dbg !69104  ret ptr %i1, !dbg !69105}106define hidden swifttailcc void @coroutineA.0(ptr %arg, ptr %arg1) !dbg !70 {107  musttail call swifttailcc void %arg(ptr swiftasync %arg1), !dbg !71108  ret void, !dbg !71109}110define hidden swifttailcc void @coroutineA.0.1(ptr %arg, ptr %arg1) !dbg !72 {111  musttail call swifttailcc void %arg(ptr swiftasync %arg1), !dbg !73112  ret void, !dbg !73113}114define swifttailcc void @coroutineB(ptr swiftasync %arg) !dbg !37 {115  %i2 = call token @llvm.coro.id.async(i32 16, i32 16, i32 0, ptr nonnull @coroutineBTu)116  %i3 = call ptr @llvm.coro.begin(token %i2, ptr null)117  %i6 = getelementptr inbounds <{ ptr, ptr }>, ptr %arg, i64 0, i32 1, !dbg !42118  %i712 = load ptr, ptr %i6, align 8, !dbg !42119  call void (ptr, i1, ...) @llvm.coro.end.async(ptr %i3, i1 false, ptr nonnull @coroutineB.0, ptr %i712, ptr %arg), !dbg !42120  unreachable, !dbg !42121}122define hidden swifttailcc void @coroutineB.0(ptr %arg, ptr %arg1) !dbg !44 {123  musttail call swifttailcc void %arg(ptr swiftasync %arg1), !dbg !47124  ret void, !dbg !47125}126 127declare void @llvm.coro.end.async(ptr, i1, ...)128declare ptr @llvm.coro.async.resume()129declare ptr @llvm.coro.begin(token, ptr writeonly)130declare ptr @llvm.swift.async.context.addr()131declare swiftcc ptr @swift_task_alloc(i64)132declare swiftcc void @swift_task_dealloc(ptr)133declare swifttailcc void @swift_task_switch(ptr, ptr, i64, i64)134declare token @llvm.coro.id.async(i32, i32, i32, ptr)135declare void @dont_optimize(ptr, ptr)136declare void @llvm.dbg.declare(metadata, metadata, metadata)137declare void @llvm.dbg.value(metadata, metadata, metadata)138declare { ptr } @llvm.coro.suspend.async.sl_p0s(i32, ptr, ptr, ...)139 140!llvm.module.flags = !{!6, !7}141!llvm.dbg.cu = !{!16}142 143!6 = !{i32 7, !"Dwarf Version", i32 4}144!7 = !{i32 2, !"Debug Info Version", i32 3}145 146!50 = !DILocalVariable(name: "k1", scope: !48, file: !17, line: 7, type: !53)147!500 = !DILocalVariable(name: "k2", scope: !48, file: !17, line: 7, type: !53)148!501 = !DILocalVariable(name: "k3", scope: !48, file: !17, line: 7, type: !53)149!49 = !{!50, !500}150 151!16 = distinct !DICompileUnit(language: DW_LANG_Swift, file: !17, producer: "", emissionKind: FullDebug)152!17 = !DIFile(filename: "blah", directory: "")153 154!53 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Klass")155!46 = !DISubroutineType(types: null)156 157!64 = distinct !DISubprogram(linkageName: "blah", file: !17, type: !46, unit: !16)158!68 = distinct !DISubprogram(linkageName: "blah", file: !17, type: !46, unit: !16)159!66 = distinct !DISubprogram(linkageName: "coroutineA", file: !17, type: !46, unit: !16)160!70 = distinct !DISubprogram(linkageName: "coroutineA", file: !17, type: !46, unit: !16)161!72 = distinct !DISubprogram(linkageName: "coroutineA", file: !17, type: !46, unit: !16)162!48 = distinct !DISubprogram(linkageName: "coroutineA", file: !17, type: !46, unit: !16, retainedNodes: !49)163!37 = distinct !DISubprogram(linkageName: "coroutineB", file: !17, type: !46, unit: !16)164!44 = distinct !DISubprogram(linkageName: "coroutineB", file: !17, type: !46, unit: !16)165!65 = !DILocation(line: 0, scope: !64)166!67 = !DILocation(line: 0, scope: !66)167!69 = !DILocation(line: 0, scope: !68)168!71 = !DILocation(line: 0, scope: !70)169!73 = !DILocation(line: 0, scope: !72)170!54 = !DILocation(line: 6, scope: !48)171!55 = !DILocation(line: 0, scope: !48)172!42 = !DILocation(line: 3, scope: !37)173!47 = !DILocation(line: 0, scope: !44)174!100 = !DILocation(line: 42, scope: !48)175