Skip to content

Commit ac681a3

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 baf1c8d commit ac681a3

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
@@ -1619,10 +1619,9 @@ static void fixupDebugInfoPostExtraction(Function &OldFunc, Function &NewFunc,
16191619
DebugLoc::replaceInlinedAtSubprogram(DL, *NewSP, Ctx, Cache));
16201620

16211621
// Loop info metadata may contain line locations. Fix them up.
1622-
auto updateLoopInfoLoc = [&Ctx, NewSP](Metadata *MD) -> Metadata * {
1622+
auto updateLoopInfoLoc = [&Ctx, &Cache, NewSP](Metadata *MD) -> Metadata * {
16231623
if (auto *Loc = dyn_cast_or_null<DILocation>(MD))
1624-
return DILocation::get(Ctx, Loc->getLine(), Loc->getColumn(), NewSP,
1625-
nullptr);
1624+
return DebugLoc::replaceInlinedAtSubprogram(Loc, *NewSP, Ctx, Cache);
16261625
return MD;
16271626
};
16281627
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(i32* %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)