[PATCH] D139851: [CodeExtractor] Use scope reparenting helper to update loop dbg loc

Felipe de Azevedo Piovezan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 12 09:03:46 PST 2022


fdeazeve created this revision.
fdeazeve added a reviewer: aprantl.
Herald added a subscriber: hiraditya.
Herald added a project: All.
fdeazeve requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Apply the same strategy from D139217 <https://reviews.llvm.org/D139217> to loop debug locations.

Depends on D139849 <https://reviews.llvm.org/D139849>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139851

Files:
  llvm/lib/Transforms/Utils/CodeExtractor.cpp
  llvm/test/Transforms/HotColdSplit/update-split-loop-metadata.ll


Index: llvm/test/Transforms/HotColdSplit/update-split-loop-metadata.ll
===================================================================
--- llvm/test/Transforms/HotColdSplit/update-split-loop-metadata.ll
+++ llvm/test/Transforms/HotColdSplit/update-split-loop-metadata.ll
@@ -11,8 +11,10 @@
 
 ; 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 @@
 !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)
Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
===================================================================
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -1624,10 +1624,9 @@
           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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139851.482154.patch
Type: text/x-patch
Size: 2088 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221212/4c0a23b0/attachment.bin>


More information about the llvm-commits mailing list