[llvm] 79d59c3 - [CodeExtractor] Only rewrite scope of labels that were not inlined
Felipe de Azevedo Piovezan via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 12 12:44:50 PST 2022
Author: Felipe de Azevedo Piovezan
Date: 2022-12-12T15:44:16-05:00
New Revision: 79d59c3f3e8abb66a758793bfd9acd8ea6b3d92b
URL: https://github.com/llvm/llvm-project/commit/79d59c3f3e8abb66a758793bfd9acd8ea6b3d92b
DIFF: https://github.com/llvm/llvm-project/commit/79d59c3f3e8abb66a758793bfd9acd8ea6b3d92b.diff
LOG: [CodeExtractor] Only rewrite scope of labels that were not inlined
dbg.labels that were inlined from other functions should have their
scope preserved upon outlining for the same reasons described in
D139669.
Added:
Modified:
llvm/lib/Transforms/Utils/CodeExtractor.cpp
llvm/test/Transforms/HotColdSplit/split-out-dbg-label.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
index feb2a0eaffedc..4c373f72e05b6 100644
--- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -1562,8 +1562,11 @@ static void fixupDebugInfoPostExtraction(Function &OldFunc, Function &NewFunc,
if (!DII)
continue;
- // Point the intrinsic to a fresh label within the new function.
+ // Point the intrinsic to a fresh label within the new function if the
+ // intrinsic was not inlined from some other function.
if (auto *DLI = dyn_cast<DbgLabelInst>(&I)) {
+ if (DLI->getDebugLoc().getInlinedAt())
+ continue;
DILabel *OldLabel = DLI->getLabel();
DINode *&NewLabel = RemappedMetadata[OldLabel];
if (!NewLabel)
diff --git a/llvm/test/Transforms/HotColdSplit/split-out-dbg-label.ll b/llvm/test/Transforms/HotColdSplit/split-out-dbg-label.ll
index e62f13bb34ac8..64fe2fa914502 100644
--- a/llvm/test/Transforms/HotColdSplit/split-out-dbg-label.ll
+++ b/llvm/test/Transforms/HotColdSplit/split-out-dbg-label.ll
@@ -12,11 +12,15 @@ target triple = "x86_64-apple-macosx10.14.0"
; CHECK-LABEL: define {{.*}}@foo.cold.1
; CHECK: llvm.dbg.label(metadata [[LABEL:![0-9]+]]), !dbg [[LINE:![0-9]+]]
+; CHECK: llvm.dbg.label(metadata [[LABEL_IN_INLINE_ME:![0-9]+]]), !dbg [[LINE2:![0-9]+]]
; CHECK: [[FILE:![0-9]+]] = !DIFile
+; CHECK: [[INLINE_ME_SCOPE:![0-9]+]] = distinct !DISubprogram(name: "inline_me"
; CHECK: [[SCOPE:![0-9]+]] = distinct !DISubprogram(name: "foo.cold.1"
; CHECK: [[LINE]] = !DILocation(line: 1, column: 1, scope: [[SCOPE]]
; CHECK: [[LABEL]] = !DILabel(scope: [[SCOPE]], name: "bye", file: [[FILE]], line: 28
+; CHECK: [[LABEL_IN_INLINE_ME]] = !DILabel(scope: [[INLINE_ME_SCOPE]], name: "label_in_ at inline_me", file: [[FILE]], line: 29
+; CHECK: [[LINE2]] = !DILocation(line: 2, column: 2, scope: [[INLINE_ME_SCOPE]], inlinedAt: [[LINE]]
define void @foo(i32 %arg1) !dbg !6 {
entry:
@@ -28,6 +32,7 @@ if.then: ; preds = %entry
if.end: ; preds = %entry
call void @llvm.dbg.label(metadata !12), !dbg !11
+ call void @llvm.dbg.label(metadata !14), !dbg !15
call void @sink()
ret void
}
@@ -36,6 +41,10 @@ declare void @llvm.dbg.label(metadata)
declare void @sink() cold
+define void @inline_me() !dbg !13 {
+ ret void
+}
+
!llvm.dbg.cu = !{!0}
!llvm.debugify = !{!3, !4}
!llvm.module.flags = !{!5}
@@ -53,3 +62,6 @@ declare void @sink() cold
!10 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)
!11 = !DILocation(line: 1, column: 1, scope: !6)
!12 = !DILabel(scope: !6, name: "bye", file: !1, line: 28)
+!13 = distinct !DISubprogram(name: "inline_me", linkageName: "inline_me", scope: null, file: !1, line: 1, type: !7, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: true, unit: !0, retainedNodes: !8)
+!14 = !DILabel(scope: !13, name: "label_in_ at inline_me", file: !1, line: 29)
+!15 = !DILocation(line: 2, column: 2, scope: !13, inlinedAt: !11)
More information about the llvm-commits
mailing list