1360abb7eSVedant Kumar; RUN: opt -hotcoldsplit -hotcoldsplit-threshold=0 -S < %s | FileCheck %s
2360abb7eSVedant Kumar
3360abb7eSVedant Kumar; Check that llvm.loop metadata extracted by CodeExtractor is updated so that
4360abb7eSVedant Kumar; the debug locations it contains have the right scope.
5360abb7eSVedant Kumar
6360abb7eSVedant Kumartarget datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
7360abb7eSVedant Kumartarget triple = "x86_64-apple-macosx10.14.0"
8360abb7eSVedant Kumar
9360abb7eSVedant Kumar; CHECK-LABEL: define {{.*}}@basic.cold.1
10360abb7eSVedant Kumar; CHECK: br i1 {{.*}}, !llvm.loop [[LOOP_MD:![0-9]+]]
11360abb7eSVedant Kumar
12360abb7eSVedant Kumar; The scope for these debug locations should be @basic.cold.1, not @basic.
13360abb7eSVedant Kumar; CHECK: [[SCOPE:![0-9]+]] = distinct !DISubprogram(name: "basic.cold.1"
14360abb7eSVedant Kumar; CHECK: [[LOOP_MD]] = distinct !{[[LOOP_MD]], [[LINE:![0-9]+]], [[LINE]]}
15360abb7eSVedant Kumar; CHECK: [[LINE]] = !DILocation(line: 1, column: 1, scope: [[SCOPE]])
16360abb7eSVedant Kumar
17*0628bea5SHans Wennborgdefine void @basic(i32* %p, i32 %k) !dbg !6 {
18360abb7eSVedant Kumarentry:
19360abb7eSVedant Kumar  %cmp3 = icmp slt i32 0, %k
20360abb7eSVedant Kumar  br i1 %cmp3, label %for.body.lr.ph, label %for.end
21360abb7eSVedant Kumar
22360abb7eSVedant Kumarfor.body.lr.ph:                                   ; preds = %entry
23360abb7eSVedant Kumar  br label %for.body
24360abb7eSVedant Kumar
25360abb7eSVedant Kumarfor.body:                                         ; preds = %for.body.lr.ph, %for.body
26360abb7eSVedant Kumar  %i.05 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
27360abb7eSVedant Kumar  %p.addr.04 = phi i32* [ %p, %for.body.lr.ph ], [ %incdec.ptr, %for.body ]
28360abb7eSVedant Kumar  %incdec.ptr = getelementptr inbounds i32, i32* %p.addr.04, i32 1
29360abb7eSVedant Kumar  store i32 %i.05, i32* %p.addr.04, align 4
30360abb7eSVedant Kumar  %inc = add nsw i32 %i.05, 1
31360abb7eSVedant Kumar  call void @sink()
32360abb7eSVedant Kumar  %cmp = icmp slt i32 %inc, %k
33360abb7eSVedant Kumar  br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge, !llvm.loop !10
34360abb7eSVedant Kumar
35360abb7eSVedant Kumarfor.cond.for.end_crit_edge:                       ; preds = %for.body
36360abb7eSVedant Kumar  br label %for.end
37360abb7eSVedant Kumar
38360abb7eSVedant Kumarfor.end:                                          ; preds = %for.cond.for.end_crit_edge, %entry
39360abb7eSVedant Kumar  ret void
40360abb7eSVedant Kumar}
41360abb7eSVedant Kumar
42360abb7eSVedant Kumardeclare void @sink() cold
43360abb7eSVedant Kumar
44360abb7eSVedant Kumar!llvm.dbg.cu = !{!0}
45360abb7eSVedant Kumar!llvm.debugify = !{!3, !4}
46360abb7eSVedant Kumar!llvm.module.flags = !{!5}
47360abb7eSVedant Kumar
48360abb7eSVedant Kumar!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
49360abb7eSVedant Kumar!1 = !DIFile(filename: "<stdin>", directory: "/")
50360abb7eSVedant Kumar!2 = !{}
51360abb7eSVedant Kumar!3 = !{i32 22}
52360abb7eSVedant Kumar!4 = !{i32 12}
53360abb7eSVedant Kumar!5 = !{i32 2, !"Debug Info Version", i32 3}
54360abb7eSVedant Kumar!6 = distinct !DISubprogram(name: "basic", linkageName: "basic", scope: null, file: !1, line: 1, type: !7, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8)
55360abb7eSVedant Kumar!7 = !DISubroutineType(types: !2)
56360abb7eSVedant Kumar!8 = !{}
57360abb7eSVedant Kumar!9 = !DILocation(line: 1, column: 1, scope: !6)
58360abb7eSVedant Kumar!10 = distinct !{!10, !9, !9}
59