Skip to content

Commit 1833de3

Browse files
authored
[Extractor][DebugInfo] Don't pick DebugLocs from dbg intrinsics (#80863)
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.
1 parent 0fb9f68 commit 1833de3

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

llvm/lib/Transforms/Utils/CodeExtractor.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,6 +1769,10 @@ CodeExtractor::extractCodeRegion(const CodeExtractorAnalysisCache &CEAC,
17691769
return any_of(*BB, [&BranchI](const Instruction &I) {
17701770
if (!I.getDebugLoc())
17711771
return false;
1772+
// Don't use source locations attached to debug-intrinsics: they could
1773+
// be from completely unrelated scopes.
1774+
if (isa<DbgInfoIntrinsic>(I))
1775+
return false;
17721776
BranchI->setDebugLoc(I.getDebugLoc());
17731777
return true;
17741778
});

llvm/test/Transforms/HotColdSplit/split-out-dbg-label.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ target triple = "x86_64-apple-macosx10.14.0"
1818
; CHECK: [[FILE:![0-9]+]] = !DIFile
1919
; CHECK: [[INLINE_ME_SCOPE:![0-9]+]] = distinct !DISubprogram(name: "inline_me"
2020
; CHECK: [[SCOPE:![0-9]+]] = distinct !DISubprogram(name: "foo.cold.1"
21-
; CHECK: [[LINE]] = !DILocation(line: 1, column: 1, scope: [[SCOPE]]
2221
; CHECK: [[LABEL]] = !DILabel(scope: [[SCOPE]], name: "bye", file: [[FILE]], line: 28
22+
; CHECK: [[LINE]] = !DILocation(line: 1, column: 1, scope: [[SCOPE]]
2323
; CHECK: [[LABEL_IN_INLINE_ME]] = !DILabel(scope: [[INLINE_ME_SCOPE]], name: "label_in_@inline_me", file: [[FILE]], line: 29
2424
; CHECK: [[LINE2]] = !DILocation(line: 2, column: 2, scope: [[INLINE_ME_SCOPE]], inlinedAt: [[LINE]]
2525
; CHECK: [[SCOPED_LABEL]] = !DILabel(scope: [[SCOPE_IN_FOO:![0-9]+]], name: "scoped_label_in_foo", file: [[FILE]], line: 30

llvm/test/Transforms/IROutliner/gvn-phi-debug.ll

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
22
; RUN: opt -S -passes=verify,iroutliner -ir-outlining-no-cost < %s | FileCheck %s
3+
; RUN: opt -S -passes=verify,iroutliner -ir-outlining-no-cost < %s --try-experimental-debuginfo-iterators | FileCheck %s
34

45
target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
56
target triple = "thumbv7-none-linux-android19"
@@ -171,7 +172,5 @@ attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memo
171172
; 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]+]])
172173
; CHECK: [[META9]] = !DISubroutineType(types: [[META10]])
173174
; CHECK: [[META10]] = !{}
174-
; CHECK: [[DBG11]] = !DILocation(line: 0, scope: [[META12:![0-9]+]])
175-
; CHECK: [[META12]] = distinct !DILexicalBlock(scope: [[META13:![0-9]+]], file: [[META5]], line: 56, column: 17)
176-
; CHECK: [[META13]] = distinct !DILexicalBlock(scope: [[DBG8]], file: [[META5]], line: 56, column: 11)
175+
; CHECK: [[DBG11]] = !DILocation(line: 0, scope: [[DBG8]])
177176
;.

0 commit comments

Comments
 (0)