-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Extractor][DebugInfo] Don't pick DebugLocs from dbg intrinsics #80863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
When picking the source location for a branch instruction in the CodeExtractor, we can end up picking the source location of a debugging intrinsic. This never makes sense because any variable assignment information (or labels) might originate from completely different lexical scopes that have been inlined, and also makes the line tables change between -g and -gmlt. Fix this by skipping debug intrinsics when looking for branch source locations. Detected because of test differences with RemoveDIs, the non-intrinsinc form of debug-info -- fixing in intrinsic form to avoid there being spurious test differences when we turn it on.
@llvm/pr-subscribers-llvm-transforms @llvm/pr-subscribers-debuginfo Author: Jeremy Morse (jmorse) ChangesWhen picking the source location for a branch instruction in the CodeExtractor, we can end up picking the source location of a debugging intrinsic. This never makes sense because any variable assignment information (or labels) might originate from completely different lexical scopes that have been inlined, and also makes the line tables change between -g and -gmlt. Fix this by skipping debug intrinsics when looking for branch source locations. Detected because of test differences with RemoveDIs, the non-intrinsinc form of debug-info -- fixing in intrinsic form to avoid there being spurious test differences when we turn it on. Full diff: https://github.com/llvm/llvm-project/pull/80863.diff 3 Files Affected:
diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
index 278111883459b..57d3926515993 100644
--- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -1769,6 +1769,10 @@ CodeExtractor::extractCodeRegion(const CodeExtractorAnalysisCache &CEAC,
return any_of(*BB, [&BranchI](const Instruction &I) {
if (!I.getDebugLoc())
return false;
+ // Don't use source locations attached to debug-intrinsics: they could
+ // be from completely unrelated scopes.
+ if (isa<DbgInfoIntrinsic>(I))
+ return false;
BranchI->setDebugLoc(I.getDebugLoc());
return true;
});
diff --git a/llvm/test/Transforms/HotColdSplit/split-out-dbg-label.ll b/llvm/test/Transforms/HotColdSplit/split-out-dbg-label.ll
index 8209f93915e9c..97bb13d4bdcfb 100644
--- a/llvm/test/Transforms/HotColdSplit/split-out-dbg-label.ll
+++ b/llvm/test/Transforms/HotColdSplit/split-out-dbg-label.ll
@@ -18,8 +18,8 @@ target triple = "x86_64-apple-macosx10.14.0"
; 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: [[LINE]] = !DILocation(line: 1, column: 1, scope: [[SCOPE]]
; CHECK: [[LABEL_IN_INLINE_ME]] = !DILabel(scope: [[INLINE_ME_SCOPE]], name: "label_in_@inline_me", file: [[FILE]], line: 29
; CHECK: [[LINE2]] = !DILocation(line: 2, column: 2, scope: [[INLINE_ME_SCOPE]], inlinedAt: [[LINE]]
; CHECK: [[SCOPED_LABEL]] = !DILabel(scope: [[SCOPE_IN_FOO:![0-9]+]], name: "scoped_label_in_foo", file: [[FILE]], line: 30
diff --git a/llvm/test/Transforms/IROutliner/gvn-phi-debug.ll b/llvm/test/Transforms/IROutliner/gvn-phi-debug.ll
index 934bda1fc7c2e..217a8498ffbb3 100644
--- a/llvm/test/Transforms/IROutliner/gvn-phi-debug.ll
+++ b/llvm/test/Transforms/IROutliner/gvn-phi-debug.ll
@@ -1,5 +1,6 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
; RUN: opt -S -passes=verify,iroutliner -ir-outlining-no-cost < %s | FileCheck %s
+; RUN: opt -S -passes=verify,iroutliner -ir-outlining-no-cost < %s --try-experimental-debuginfo-iterators | FileCheck %s
target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "thumbv7-none-linux-android19"
@@ -171,7 +172,5 @@ attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memo
; CHECK: [[DBG8]] = distinct !DISubprogram(name: "w", scope: [[META5]], file: [[META5]], line: 54, type: [[META9:![0-9]+]], scopeLine: 54, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: [[META0]], retainedNodes: [[META10:![0-9]+]])
; CHECK: [[META9]] = !DISubroutineType(types: [[META10]])
; CHECK: [[META10]] = !{}
-; CHECK: [[DBG11]] = !DILocation(line: 0, scope: [[META12:![0-9]+]])
-; CHECK: [[META12]] = distinct !DILexicalBlock(scope: [[META13:![0-9]+]], file: [[META5]], line: 56, column: 17)
-; CHECK: [[META13]] = distinct !DILexicalBlock(scope: [[DBG8]], file: [[META5]], line: 56, column: 11)
+; CHECK: [[DBG11]] = !DILocation(line: 0, scope: [[DBG8]])
;.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, LGTM.
When picking the source location for a branch instruction in the CodeExtractor, we can end up picking the source location of a debugging intrinsic. This never makes sense because any variable assignment information (or labels) might originate from completely different lexical scopes that have been inlined, and also makes the line tables change between -g and -gmlt. Fix this by skipping debug intrinsics when looking for branch source locations.
Detected because of test differences with RemoveDIs, the non-intrinsinc form of debug-info -- fixing in intrinsic form to avoid there being spurious test differences when we turn it on.