xref: /llvm-project/llvm/test/Transforms/HotColdSplit/update-split-loop-metadata.ll (revision cde2cc9a8f46acfa1f92b127de28748943dc2de8)
1; RUN: opt -passes=hotcoldsplit -hotcoldsplit-threshold=0 -S < %s | FileCheck %s
2
3; Check that llvm.loop metadata extracted by CodeExtractor is updated so that
4; the debug locations it contains have the right scope.
5
6target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
7target triple = "x86_64-apple-macosx10.14.0"
8
9; CHECK-LABEL: define {{.*}}@basic.cold.1
10; CHECK: br i1 {{.*}}, !llvm.loop [[LOOP_MD:![0-9]+]]
11
12; The scope for these debug locations should be @basic.cold.1, not @basic.
13; CHECK: [[SCOPE:![0-9]+]] = distinct !DISubprogram(name: "basic.cold.1"
14; CHECK: [[LOOP_MD]] = distinct !{[[LOOP_MD]], [[LINE:![0-9]+]], [[LINE2:![0-9]+]]}
15; CHECK: [[LINE]] = !DILocation(line: 1, column: 1, scope: [[SCOPE]])
16; CHECK: [[LINE2]] = !DILocation(line: 2, column: 2, scope: [[LEX_SCOPE:![0-9]+]])
17; CHECK: [[LEX_SCOPE]] = !DILexicalBlock(scope: [[SCOPE]], file: !{{[0-9]+}}, line: 3, column: 3)
18
19define void @basic(ptr %p, i32 %k) !dbg !6 {
20entry:
21  %cmp3 = icmp slt i32 0, %k
22  br i1 %cmp3, label %for.body.lr.ph, label %for.end
23
24for.body.lr.ph:                                   ; preds = %entry
25  br label %for.body
26
27for.body:                                         ; preds = %for.body.lr.ph, %for.body
28  %i.05 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
29  %p.addr.04 = phi ptr [ %p, %for.body.lr.ph ], [ %incdec.ptr, %for.body ]
30  %incdec.ptr = getelementptr inbounds i32, ptr %p.addr.04, i32 1
31  store i32 %i.05, ptr %p.addr.04, align 4
32  %inc = add nsw i32 %i.05, 1
33  call void @sink()
34  %cmp = icmp slt i32 %inc, %k
35  br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge, !llvm.loop !10
36
37for.cond.for.end_crit_edge:                       ; preds = %for.body
38  br label %for.end
39
40for.end:                                          ; preds = %for.cond.for.end_crit_edge, %entry
41  ret void
42}
43
44declare void @sink() cold
45
46!llvm.dbg.cu = !{!0}
47!llvm.debugify = !{!3, !4}
48!llvm.module.flags = !{!5}
49
50!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
51!1 = !DIFile(filename: "<stdin>", directory: "/")
52!2 = !{}
53!3 = !{i32 22}
54!4 = !{i32 12}
55!5 = !{i32 2, !"Debug Info Version", i32 3}
56!6 = distinct !DISubprogram(name: "basic", linkageName: "basic", scope: null, file: !1, line: 1, type: !7, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8)
57!7 = !DISubroutineType(types: !2)
58!8 = !{}
59!9 = !DILocation(line: 1, column: 1, scope: !6)
60!10 = distinct !{!10, !9, !11}
61!11 = !DILocation(line: 2, column: 2, scope: !12)
62!12 = !DILexicalBlock(scope: !6, file: !1, line: 3, column: 3)
63