xref: /llvm-project/llvm/test/Transforms/Coroutines/coro-split-dbg.ll (revision fd8fa31c55a3413f643443ecf3301441428ce513)
1; Make sure that coro-split correctly deals with debug information.
2; The test here is simply that it does not result in bad IR that will crash opt.
3; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -disable-output
4; RUN: opt --try-experimental-debuginfo-iterators < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -disable-output
5source_filename = "coro.c"
6target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
7target triple = "x86_64-unknown-linux-gnu"
8
9; Function Attrs: nounwind readnone
10declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
11
12declare void @bar(...) local_unnamed_addr #2
13
14; Function Attrs: nounwind uwtable
15define ptr @f() #3 !dbg !16 {
16entry:
17  %0 = tail call token @llvm.coro.id(i32 0, ptr null, ptr @f, ptr null), !dbg !26
18  %1 = tail call i64 @llvm.coro.size.i64(), !dbg !26
19  %call = tail call ptr @malloc(i64 %1), !dbg !26
20  %2 = tail call ptr @llvm.coro.begin(token %0, ptr %call) #9, !dbg !26
21  tail call void @llvm.dbg.value(metadata ptr %2, metadata !21, metadata !12), !dbg !26
22  br label %for.cond, !dbg !27
23
24for.cond:                                         ; preds = %for.cond, %entry
25  tail call void @llvm.dbg.value(metadata i32 undef, metadata !22, metadata !12), !dbg !28
26  tail call void @llvm.dbg.value(metadata i32 undef, metadata !11, metadata !12) #7, !dbg !29
27  tail call void (...) @bar() #7, !dbg !33
28  %3 = tail call token @llvm.coro.save(ptr null), !dbg !34
29  %4 = tail call i8 @llvm.coro.suspend(token %3, i1 false), !dbg !34
30  %conv = sext i8 %4 to i32, !dbg !34
31  switch i32 %conv, label %coro_Suspend [
32    i32 0, label %for.cond
33    i32 1, label %coro_Cleanup
34  ], !dbg !34
35
36coro_Cleanup:                                     ; preds = %for.cond
37  %5 = tail call ptr @llvm.coro.free(token %0, ptr %2), !dbg !35
38  tail call void @free(ptr nonnull %5), !dbg !36
39  br label %coro_Suspend, !dbg !36
40
41coro_Suspend:                                     ; preds = %for.cond, %if.then, %coro_Cleanup
42  tail call i1 @llvm.coro.end(ptr null, i1 false, token none) #9, !dbg !38
43  ret ptr %2, !dbg !39
44}
45
46; Function Attrs: argmemonly nounwind
47declare void @llvm.lifetime.start.p0(i64, ptr nocapture) #4
48
49; Function Attrs: argmemonly nounwind readonly
50declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr) #5
51
52; Function Attrs: nounwind
53declare noalias ptr @malloc(i64) local_unnamed_addr #6
54declare i64 @llvm.coro.size.i64() #1
55declare ptr @llvm.coro.begin(token, ptr writeonly) #7
56declare token @llvm.coro.save(ptr) #7
57declare i8 @llvm.coro.suspend(token, i1) #7
58declare void @llvm.lifetime.end.p0(i64, ptr nocapture) #4
59declare ptr @llvm.coro.free(token, ptr nocapture readonly) #5
60declare void @free(ptr nocapture) local_unnamed_addr #6
61declare i1 @llvm.coro.end(ptr, i1, token) #7
62declare ptr @llvm.coro.subfn.addr(ptr nocapture readonly, i8) #5
63
64declare void @llvm.dbg.value(metadata, metadata, metadata) #1
65
66attributes #0 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
67attributes #1 = { nounwind readnone }
68attributes #2 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
69attributes #3 = { nounwind uwtable presplitcoroutine "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
70attributes #4 = { argmemonly nounwind }
71attributes #5 = { argmemonly nounwind readonly }
72attributes #6 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
73attributes #7 = { nounwind }
74attributes #8 = { alwaysinline nounwind }
75attributes #9 = { noduplicate }
76
77!llvm.dbg.cu = !{!0}
78!llvm.module.flags = !{!3, !4}
79!llvm.ident = !{!5}
80
81!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 4.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
82!1 = !DIFile(filename: "coro.c", directory: "/home/gor/build/bin")
83!2 = !{}
84!3 = !{i32 2, !"Dwarf Version", i32 4}
85!4 = !{i32 2, !"Debug Info Version", i32 3}
86!5 = !{!"clang version 4.0.0"}
87!6 = distinct !DISubprogram(name: "print", scope: !1, file: !1, line: 6, type: !7, isLocal: false, isDefinition: true, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !10)
88!7 = !DISubroutineType(types: !8)
89!8 = !{null, !9}
90!9 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
91!10 = !{!11}
92!11 = !DILocalVariable(name: "v", arg: 1, scope: !6, file: !1, line: 6, type: !9)
93!12 = !DIExpression()
94!13 = !DILocation(line: 6, column: 16, scope: !6)
95!14 = !DILocation(line: 6, column: 19, scope: !6)
96!15 = !DILocation(line: 6, column: 25, scope: !6)
97!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)
98!17 = !DISubroutineType(types: !18)
99!18 = !{!19}
100!19 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64, align: 64)
101!20 = !{!21, !22, !24}
102!21 = !DILocalVariable(name: "coro_hdl", scope: !16, file: !1, line: 9, type: !19)
103!22 = !DILocalVariable(name: "i", scope: !23, file: !1, line: 11, type: !9)
104!23 = distinct !DILexicalBlock(scope: !16, file: !1, line: 11, column: 3)
105!24 = !DILocalVariable(name: "coro_mem", scope: !25, file: !1, line: 16, type: !19)
106!25 = distinct !DILexicalBlock(scope: !16, file: !1, line: 16, column: 3)
107!26 = !DILocation(line: 9, column: 3, scope: !16)
108!27 = !DILocation(line: 11, column: 8, scope: !23)
109!28 = !DILocation(line: 11, column: 12, scope: !23)
110!29 = !DILocation(line: 6, column: 16, scope: !6, inlinedAt: !30)
111!30 = distinct !DILocation(line: 12, column: 5, scope: !31)
112!31 = distinct !DILexicalBlock(scope: !32, file: !1, line: 11, column: 25)
113!32 = distinct !DILexicalBlock(scope: !23, file: !1, line: 11, column: 3)
114!33 = !DILocation(line: 6, column: 19, scope: !6, inlinedAt: !30)
115!34 = !DILocation(line: 13, column: 5, scope: !31)
116!35 = !DILocation(line: 16, column: 3, scope: !25)
117!36 = !DILocation(line: 16, column: 3, scope: !37)
118!37 = distinct !DILexicalBlock(scope: !25, file: !1, line: 16, column: 3)
119!38 = !DILocation(line: 16, column: 3, scope: !16)
120!39 = !DILocation(line: 17, column: 1, scope: !16)
121