Skip to content

Commit cde2cc9

Browse files
[CodeExtractor] Use scope reparenting helper to update loop dbg loc
Apply the same strategy from D139217 to loop debug locations. Differential Revision: https://reviews.llvm.org/D139851
1 parent b432dd2 commit cde2cc9

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

llvm/lib/Transforms/Utils/CodeExtractor.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,10 +1624,9 @@ static void fixupDebugInfoPostExtraction(Function &OldFunc, Function &NewFunc,
16241624
DebugLoc::replaceInlinedAtSubprogram(DL, *NewSP, Ctx, Cache));
16251625

16261626
// Loop info metadata may contain line locations. Fix them up.
1627-
auto updateLoopInfoLoc = [&Ctx, NewSP](Metadata *MD) -> Metadata * {
1627+
auto updateLoopInfoLoc = [&Ctx, &Cache, NewSP](Metadata *MD) -> Metadata * {
16281628
if (auto *Loc = dyn_cast_or_null<DILocation>(MD))
1629-
return DILocation::get(Ctx, Loc->getLine(), Loc->getColumn(), NewSP,
1630-
nullptr);
1629+
return DebugLoc::replaceInlinedAtSubprogram(Loc, *NewSP, Ctx, Cache);
16311630
return MD;
16321631
};
16331632
updateLoopMetadataDebugLocations(I, updateLoopInfoLoc);

llvm/test/Transforms/HotColdSplit/update-split-loop-metadata.ll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ target triple = "x86_64-apple-macosx10.14.0"
1111

1212
; The scope for these debug locations should be @basic.cold.1, not @basic.
1313
; CHECK: [[SCOPE:![0-9]+]] = distinct !DISubprogram(name: "basic.cold.1"
14-
; CHECK: [[LOOP_MD]] = distinct !{[[LOOP_MD]], [[LINE:![0-9]+]], [[LINE]]}
14+
; CHECK: [[LOOP_MD]] = distinct !{[[LOOP_MD]], [[LINE:![0-9]+]], [[LINE2:![0-9]+]]}
1515
; 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)
1618

1719
define void @basic(ptr %p, i32 %k) !dbg !6 {
1820
entry:
@@ -55,4 +57,6 @@ declare void @sink() cold
5557
!7 = !DISubroutineType(types: !2)
5658
!8 = !{}
5759
!9 = !DILocation(line: 1, column: 1, scope: !6)
58-
!10 = distinct !{!10, !9, !9}
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)

0 commit comments

Comments
 (0)