[llvm] cde2cc9 - [CodeExtractor] Use scope reparenting helper to update loop dbg loc
Felipe de Azevedo Piovezan via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 12 12:51:25 PST 2022
Author: Felipe de Azevedo Piovezan
Date: 2022-12-12T15:50:52-05:00
New Revision: cde2cc9a8f46acfa1f92b127de28748943dc2de8
URL: https://github.com/llvm/llvm-project/commit/cde2cc9a8f46acfa1f92b127de28748943dc2de8
DIFF: https://github.com/llvm/llvm-project/commit/cde2cc9a8f46acfa1f92b127de28748943dc2de8.diff
LOG: [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
Added:
Modified:
llvm/lib/Transforms/Utils/CodeExtractor.cpp
llvm/test/Transforms/HotColdSplit/update-split-loop-metadata.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
index babe9be9d8f9e..3aa16eb9162a5 100644
--- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -1624,10 +1624,9 @@ static void fixupDebugInfoPostExtraction(Function &OldFunc, Function &NewFunc,
DebugLoc::replaceInlinedAtSubprogram(DL, *NewSP, Ctx, Cache));
// Loop info metadata may contain line locations. Fix them up.
- auto updateLoopInfoLoc = [&Ctx, NewSP](Metadata *MD) -> Metadata * {
+ auto updateLoopInfoLoc = [&Ctx, &Cache, NewSP](Metadata *MD) -> Metadata * {
if (auto *Loc = dyn_cast_or_null<DILocation>(MD))
- return DILocation::get(Ctx, Loc->getLine(), Loc->getColumn(), NewSP,
- nullptr);
+ return DebugLoc::replaceInlinedAtSubprogram(Loc, *NewSP, Ctx, Cache);
return MD;
};
updateLoopMetadataDebugLocations(I, updateLoopInfoLoc);
diff --git a/llvm/test/Transforms/HotColdSplit/update-split-loop-metadata.ll b/llvm/test/Transforms/HotColdSplit/update-split-loop-metadata.ll
index 44e8f8093db04..97ec3b5d1d2be 100644
--- a/llvm/test/Transforms/HotColdSplit/update-split-loop-metadata.ll
+++ b/llvm/test/Transforms/HotColdSplit/update-split-loop-metadata.ll
@@ -11,8 +11,10 @@ target triple = "x86_64-apple-macosx10.14.0"
; The scope for these debug locations should be @basic.cold.1, not @basic.
; CHECK: [[SCOPE:![0-9]+]] = distinct !DISubprogram(name: "basic.cold.1"
-; CHECK: [[LOOP_MD]] = distinct !{[[LOOP_MD]], [[LINE:![0-9]+]], [[LINE]]}
+; CHECK: [[LOOP_MD]] = distinct !{[[LOOP_MD]], [[LINE:![0-9]+]], [[LINE2:![0-9]+]]}
; CHECK: [[LINE]] = !DILocation(line: 1, column: 1, scope: [[SCOPE]])
+; CHECK: [[LINE2]] = !DILocation(line: 2, column: 2, scope: [[LEX_SCOPE:![0-9]+]])
+; CHECK: [[LEX_SCOPE]] = !DILexicalBlock(scope: [[SCOPE]], file: !{{[0-9]+}}, line: 3, column: 3)
define void @basic(ptr %p, i32 %k) !dbg !6 {
entry:
@@ -55,4 +57,6 @@ declare void @sink() cold
!7 = !DISubroutineType(types: !2)
!8 = !{}
!9 = !DILocation(line: 1, column: 1, scope: !6)
-!10 = distinct !{!10, !9, !9}
+!10 = distinct !{!10, !9, !11}
+!11 = !DILocation(line: 2, column: 2, scope: !12)
+!12 = !DILexicalBlock(scope: !6, file: !1, line: 3, column: 3)
More information about the llvm-commits
mailing list