Skip to content

Commit b5a273a

Browse files
authored
[Polly][DebugInfo] Use getStableDebugLoc to avoid intrinsic-dependent behaviour (#81246)
Polly currently uses `getDebugLoc` in a few places to produce diagnostic output; this is correct when interacting with specific instructions, but may be incorrect when dealing with instruction ranges if debug intrinsics are included. As a general rule, the debug locations attached to debug intrinsics may be misleading compared to the surrounding instructions, and are not generally used for anything other than determining variable scope info; the recommended approach is therefore to use `getStableDebugLoc` instead, which skips over debug intrinsics. This is necessary to fix test failures that occur when enabling non-instruction debug info, which removes debug intrinsics from basic blocks and thus alters the diagnostic output of Polly (despite causing no functional change).
1 parent 316373a commit b5a273a

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

polly/lib/Analysis/ScopDetectionDiagnostic.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void getDebugLocations(const BBPair &P, DebugLoc &Begin, DebugLoc &End) {
122122
continue;
123123
Todo.append(succ_begin(BB), succ_end(BB));
124124
for (const Instruction &Inst : *BB) {
125-
DebugLoc DL = Inst.getDebugLoc();
125+
DebugLoc DL = Inst.getStableDebugLoc();
126126
if (!DL)
127127
continue;
128128

@@ -821,7 +821,7 @@ std::string ReportUnprofitable::getEndUserMessage() const {
821821
const DebugLoc &ReportUnprofitable::getDebugLoc() const {
822822
for (const BasicBlock *BB : R->blocks())
823823
for (const Instruction &Inst : *BB)
824-
if (const DebugLoc &DL = Inst.getDebugLoc())
824+
if (const DebugLoc &DL = Inst.getStableDebugLoc())
825825
return DL;
826826

827827
return R->getEntry()->getTerminator()->getDebugLoc();

polly/lib/Support/ScopLocation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void getDebugLocation(const Region *R, unsigned &LineBegin, unsigned &LineEnd,
2525

2626
for (const BasicBlock *BB : R->blocks())
2727
for (const Instruction &Inst : *BB) {
28-
DebugLoc DL = Inst.getDebugLoc();
28+
DebugLoc DL = Inst.getStableDebugLoc();
2929
if (!DL)
3030
continue;
3131

polly/test/ScopDetectionDiagnostics/ReportLoopBound-01.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@
1919

2020
; If we reject non-affine loops the non-affine loop bound will be reported:
2121
;
22-
; REJECTNONAFFINELOOPS: remark: ReportLoopBound-01.c:1:12: The following errors keep this region from being a Scop.
22+
; REJECTNONAFFINELOOPS: remark: ReportLoopBound-01.c:2:8: The following errors keep this region from being a Scop.
2323
; REJECTNONAFFINELOOPS: remark: ReportLoopBound-01.c:2:8: Failed to derive an affine function from the loop bounds.
2424
; REJECTNONAFFINELOOPS: remark: ReportLoopBound-01.c:3:5: Invalid Scop candidate ends here.
2525

2626
; If we allow non-affine loops the non-affine access will be reported:
2727
;
28-
; ALLOWNONAFFINELOOPS: remark: ReportLoopBound-01.c:1:12: The following errors keep this region from being a Scop.
28+
; ALLOWNONAFFINELOOPS: remark: ReportLoopBound-01.c:2:8: The following errors keep this region from being a Scop.
2929
; ALLOWNONAFFINELOOPS: remark: ReportLoopBound-01.c:3:5: The array subscript of "A" is not affine
3030
; ALLOWNONAFFINELOOPS: remark: ReportLoopBound-01.c:3:5: Invalid Scop candidate ends here.
3131

3232
; If we allow non-affine loops and non-affine accesses the region will be reported as not profitable:
3333
;
34-
; ALLOWNONAFFINEALL: remark: ReportLoopBound-01.c:1:12: The following errors keep this region from being a Scop.
35-
; ALLOWNONAFFINEALL: remark: ReportLoopBound-01.c:1:12: No profitable polyhedral optimization found
34+
; ALLOWNONAFFINEALL: remark: ReportLoopBound-01.c:2:8: The following errors keep this region from being a Scop.
35+
; ALLOWNONAFFINEALL: remark: ReportLoopBound-01.c:2:8: No profitable polyhedral optimization found
3636
; ALLOWNONAFFINEALL: remark: ReportLoopBound-01.c:3:5: Invalid Scop candidate ends here.
3737

3838
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"

polly/test/ScopDetectionDiagnostics/loop_has_multiple_exits.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
;
33
; Derived from test-suite/MultiSource/Benchmarks/BitBench/uuencode/uuencode.c
44
;
5-
; CHECK: remark: uuencode.c:75:18: The following errors keep this region from being a Scop.
5+
; CHECK: remark: uuencode.c:76:13: The following errors keep this region from being a Scop.
66
; CHECK: remark: uuencode.c:83:3: Loop cannot be handled because it has multiple exits.
77
; CHECK: remark: uuencode.c:95:21: Invalid Scop candidate ends here.
88

0 commit comments

Comments
 (0)