14d211ac8SRoman Lebedev; RUN: opt -passes=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" 14*cde2cc9aSFelipe de Azevedo Piovezan; CHECK: [[LOOP_MD]] = distinct !{[[LOOP_MD]], [[LINE:![0-9]+]], [[LINE2:![0-9]+]]} 15360abb7eSVedant Kumar; CHECK: [[LINE]] = !DILocation(line: 1, column: 1, scope: [[SCOPE]]) 16*cde2cc9aSFelipe de Azevedo Piovezan; CHECK: [[LINE2]] = !DILocation(line: 2, column: 2, scope: [[LEX_SCOPE:![0-9]+]]) 17*cde2cc9aSFelipe de Azevedo Piovezan; CHECK: [[LEX_SCOPE]] = !DILexicalBlock(scope: [[SCOPE]], file: !{{[0-9]+}}, line: 3, column: 3) 18360abb7eSVedant Kumar 195e3a5d16SMatt Arsenaultdefine void @basic(ptr %p, i32 %k) !dbg !6 { 20360abb7eSVedant Kumarentry: 21360abb7eSVedant Kumar %cmp3 = icmp slt i32 0, %k 22360abb7eSVedant Kumar br i1 %cmp3, label %for.body.lr.ph, label %for.end 23360abb7eSVedant Kumar 24360abb7eSVedant Kumarfor.body.lr.ph: ; preds = %entry 25360abb7eSVedant Kumar br label %for.body 26360abb7eSVedant Kumar 27360abb7eSVedant Kumarfor.body: ; preds = %for.body.lr.ph, %for.body 28360abb7eSVedant Kumar %i.05 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ] 295e3a5d16SMatt Arsenault %p.addr.04 = phi ptr [ %p, %for.body.lr.ph ], [ %incdec.ptr, %for.body ] 305e3a5d16SMatt Arsenault %incdec.ptr = getelementptr inbounds i32, ptr %p.addr.04, i32 1 315e3a5d16SMatt Arsenault store i32 %i.05, ptr %p.addr.04, align 4 32360abb7eSVedant Kumar %inc = add nsw i32 %i.05, 1 33360abb7eSVedant Kumar call void @sink() 34360abb7eSVedant Kumar %cmp = icmp slt i32 %inc, %k 35360abb7eSVedant Kumar br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge, !llvm.loop !10 36360abb7eSVedant Kumar 37360abb7eSVedant Kumarfor.cond.for.end_crit_edge: ; preds = %for.body 38360abb7eSVedant Kumar br label %for.end 39360abb7eSVedant Kumar 40360abb7eSVedant Kumarfor.end: ; preds = %for.cond.for.end_crit_edge, %entry 41360abb7eSVedant Kumar ret void 42360abb7eSVedant Kumar} 43360abb7eSVedant Kumar 44360abb7eSVedant Kumardeclare void @sink() cold 45360abb7eSVedant Kumar 46360abb7eSVedant Kumar!llvm.dbg.cu = !{!0} 47360abb7eSVedant Kumar!llvm.debugify = !{!3, !4} 48360abb7eSVedant Kumar!llvm.module.flags = !{!5} 49360abb7eSVedant Kumar 50360abb7eSVedant Kumar!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) 51360abb7eSVedant Kumar!1 = !DIFile(filename: "<stdin>", directory: "/") 52360abb7eSVedant Kumar!2 = !{} 53360abb7eSVedant Kumar!3 = !{i32 22} 54360abb7eSVedant Kumar!4 = !{i32 12} 55360abb7eSVedant Kumar!5 = !{i32 2, !"Debug Info Version", i32 3} 56360abb7eSVedant 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) 57360abb7eSVedant Kumar!7 = !DISubroutineType(types: !2) 58360abb7eSVedant Kumar!8 = !{} 59360abb7eSVedant Kumar!9 = !DILocation(line: 1, column: 1, scope: !6) 60*cde2cc9aSFelipe de Azevedo Piovezan!10 = distinct !{!10, !9, !11} 61*cde2cc9aSFelipe de Azevedo Piovezan!11 = !DILocation(line: 2, column: 2, scope: !12) 62*cde2cc9aSFelipe de Azevedo Piovezan!12 = !DILexicalBlock(scope: !6, file: !1, line: 3, column: 3) 63