brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.6 KiB · 4c5d9fb Raw
155 lines · plain
1; Tests that we add DILabels for the suspend points.2;3; Check the generated LLVM:4; RUN: opt < %s -passes='cgscc(coro-split)' -S | FileCheck %s5;6; Check the generated DWARF debug info:7; REQUIRES: object-emission8; RUN: opt < %s -passes='cgscc(coro-split),coro-cleanup' \9; RUN:   | %llc_dwarf -O0 -filetype=obj -o - \10; RUN:   | llvm-dwarfdump - \11; RUN:   | FileCheck %s -check-prefix=DWARF12;13; Check that we don't emit any DILabel if in `LineTablesOnly` mode14; RUN: sed -e 's/emissionKind: FullDebug/emissionKind: LineTablesOnly/' %s \15; RUN:   | opt -passes='cgscc(coro-split)' -S \16; RUN:   | FileCheck %s -check-prefix=LINE-TABLE17 18source_filename = "coro.c"19 20declare void @bar(...) local_unnamed_addr #021declare void @baz(...) local_unnamed_addr #022 23; Roughly equivalent to:24;25; task f() {26;   while (true) {27;     bar();28;     co_await std::suspend_always{};29;     baz();30;     co_await std::suspend_always{};31;   }32; }33 34; Function Attrs: nounwind uwtable35define ptr @f() #2 !dbg !16 {36entry:37  %0 = tail call token @llvm.coro.id(i32 0, ptr null, ptr @f, ptr null), !dbg !2638  %1 = tail call i64 @llvm.coro.size.i64(), !dbg !2639  %frame = tail call ptr @malloc(i64 %1), !dbg !2640  %2 = tail call ptr @llvm.coro.begin(token %0, ptr %frame) #3, !dbg !2641  br label %loop1, !dbg !2742 43loop1:                                         ; preds = %for.cond, %entry44  tail call void (...) @bar() #0, !dbg !3345  %3 = tail call token @llvm.coro.save(ptr null), !dbg !3446  %4 = tail call i8 @llvm.coro.suspend(token %3, i1 false), !dbg !3447  switch i8 %4, label %coro_Suspend [48    i8 0, label %loop249    i8 1, label %coro_Cleanup50  ], !dbg !3451 52loop2:                                         ; preds = %for.cond, %entry53  tail call void (...) @baz() #0, !dbg !3554  %5 = tail call token @llvm.coro.save(ptr null), !dbg !3655  %6 = tail call i8 @llvm.coro.suspend(token %5, i1 false), !dbg !3656  switch i8 %6, label %coro_Suspend [57    i8 0, label %loop158    i8 1, label %coro_Cleanup59  ], !dbg !3660 61coro_Cleanup:                                     ; preds = %for.cond62  %7 = tail call ptr @llvm.coro.free(token %0, ptr %2), !dbg !3763  tail call void @free(ptr nonnull %7), !dbg !3764  br label %coro_Suspend, !dbg !3765 66coro_Suspend:                                     ; preds = %for.cond, %if.then, %coro_Cleanup67  tail call void @llvm.coro.end(ptr null, i1 false, token none) #3, !dbg !4068  ret ptr %2, !dbg !4169}70 71; Check that the resume function contains the `#dbg_label` instructions.72; CHECK-LABEL:   define ptr @f() #1 !dbg !6 {73; CHECK:         resume.0:        ; preds = %resume.entry74; CHECK-NEXT:        #dbg_label(![[RESUME_0:[0-9]+]], !{{[0-9]+}})75; CHECK:         resume.1:        ; preds = %resume.entry76; CHECK-NEXT:        #dbg_label(![[RESUME_1:[0-9]+]], !{{[0-9]+}})77 78; Check that the destroy function contains the `#dbg_label` instructions.79; CHECK-LABEL:   define internal fastcc void @f.destroy({{.*}}) #1 !dbg !38 {80; CHECK:         resume.0:        ; preds = %resume.entry81; CHECK-NEXT:        #dbg_label(![[DESTROY_0:[0-9]+]], !{{[0-9]+}})82; CHECK:         resume.1:        ; preds = %resume.entry83; CHECK-NEXT:        #dbg_label(![[DESTROY_1:[0-9]+]], !{{[0-9]+}})84 85; Check that the DILabels are correct.86; CHECK: ![[RESUME_0]] = !DILabel(scope: !{{[0-9]+}}, name: "__coro_resume_0", file: !{{[0-9]*}}, line: 12, column: 6, isArtificial: true, coroSuspendIdx: 0)87; CHECK: ![[RESUME_1]] = !DILabel(scope: !{{[0-9]+}}, name: "__coro_resume_1", file: !{{[0-9]*}}, line: 14, column: 6, isArtificial: true, coroSuspendIdx: 1)88; CHECK: ![[DESTROY_0]] = !DILabel(scope: !{{[0-9]+}}, name: "__coro_resume_0", file: !{{[0-9]*}}, line: 12, column: 6, isArtificial: true, coroSuspendIdx: 0)89; CHECK: ![[DESTROY_1]] = !DILabel(scope: !{{[0-9]+}}, name: "__coro_resume_1", file: !{{[0-9]*}}, line: 14, column: 6, isArtificial: true, coroSuspendIdx: 1)90 91; Check the we do not emit any DILabels in LineTablesOnly mode.92; The DWARF emitter cannot handle this and would run into an assertion.93; LINE-TABLE: !DICompileUnit{{.*}}LineTablesOnly94; LINE-TABLE-NOT: DILabel95 96 97; DWARF:        {{.*}}DW_TAG_label98; DWARF-NEXT:    DW_AT_name ("__coro_resume_0")99; DWARF-NEXT:    DW_AT_decl_file100; DWARF-NEXT:    DW_AT_decl_line    (12)101; DWARF-NEXT:    DW_AT_decl_column  (6)102; DWARF-NEXT:    DW_AT_artificial   (true)103; DWARF-NEXT:    DW_AT_LLVM_coro_suspend_idx (0x00)104; DWARF-NEXT:    DW_AT_low_pc105 106 107; Function Attrs: argmemonly nounwind readonly108declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr) #4109 110; Function Attrs: nounwind111declare noalias ptr @malloc(i64) local_unnamed_addr #0112declare i64 @llvm.coro.size.i64() #1113declare ptr @llvm.coro.begin(token, ptr writeonly) #0114declare token @llvm.coro.save(ptr) #0115declare i8 @llvm.coro.suspend(token, i1) #0116declare ptr @llvm.coro.free(token, ptr nocapture readonly) #4117declare void @free(ptr nocapture) local_unnamed_addr #0118declare void @llvm.coro.end(ptr, i1, token) #0119 120attributes #0 = { nounwind }121attributes #1 = { nounwind readnone }122attributes #2 = { nounwind uwtable presplitcoroutine }123attributes #3 = { noduplicate }124attributes #4 = { argmemonly nounwind readonly }125 126!llvm.dbg.cu = !{!0}127!llvm.module.flags = !{!3, !4}128!llvm.ident = !{!5}129 130!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 4.0.0 - manually edited", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)131!1 = !DIFile(filename: "coro.c", directory: "/home/gor/build/bin")132!2 = !{}133!3 = !{i32 2, !"Dwarf Version", i32 4}134!4 = !{i32 2, !"Debug Info Version", i32 3}135!5 = !{!"clang version 4.0.0 - manually edited"}136!9 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)137!16 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 8, type: !17, isLocal: false, isDefinition: true, scopeLine: 8, isOptimized: true, unit: !0, retainedNodes: !20)138!17 = !DISubroutineType(types: !18)139!18 = !{!19}140!19 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64, align: 64)141!20 = !{!21, !22, !24}142!21 = !DILocalVariable(name: "coro_hdl", scope: !16, file: !1, line: 9, type: !19)143!22 = !DILocalVariable(name: "i", scope: !23, file: !1, line: 11, type: !9)144!23 = distinct !DILexicalBlock(scope: !16, file: !1, line: 11, column: 3)145!24 = !DILocalVariable(name: "coro_mem", scope: !16, file: !1, line: 16, type: !19)146!26 = !DILocation(line: 9, column: 3, scope: !16)147!27 = !DILocation(line: 10, column: 8, scope: !23)148!33 = !DILocation(line: 11, column: 6, scope: !23)149!34 = !DILocation(line: 12, column: 6, scope: !23)150!35 = !DILocation(line: 13, column: 6, scope: !23)151!36 = !DILocation(line: 14, column: 6, scope: !23)152!37 = !DILocation(line: 16, column: 3, scope: !16)153!40 = !DILocation(line: 16, column: 3, scope: !16)154!41 = !DILocation(line: 17, column: 1, scope: !16)155