-
Notifications
You must be signed in to change notification settings - Fork 15k
[DependenceAnalysis] Improve debug messages #156367
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
@llvm/pr-subscribers-llvm-analysis Author: Sebastian Pop (sebpop) ChangesFull diff: https://github.com/llvm/llvm-project/pull/156367.diff 1 Files Affected:
diff --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp
index f33e04e804e3d..da86a8d2cc9c0 100644
--- a/llvm/lib/Analysis/DependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/DependenceAnalysis.cpp
@@ -3419,13 +3419,24 @@ bool DependenceInfo::tryDelinearizeFixedSize(
size_t SSize = Subscripts.size();
for (size_t I = 1; I < SSize; ++I) {
const SCEV *S = Subscripts[I];
- if (!isKnownNonNegative(S, Ptr))
+ if (!isKnownNonNegative(S, Ptr)) {
+ LLVM_DEBUG({
+ dbgs() << "Check failed: !isKnownNonNegative(S, Ptr)\n";
+ dbgs() << " S: " << *S << "\n" << " Ptr: " << *Ptr << "\n";
+ });
return false;
+ }
if (auto *SType = dyn_cast<IntegerType>(S->getType())) {
const SCEV *Range = SE->getConstant(
ConstantInt::get(SType, DimensionSizes[I - 1], false));
- if (!isKnownLessThan(S, Range))
+ if (!isKnownLessThan(S, Range)) {
+ LLVM_DEBUG({
+ dbgs() << "Check failed: !isKnownLessThan(S, Range)\n";
+ dbgs() << " S: " << *S << "\n"
+ << " Range: " << *Range << "\n";
+ });
return false;
+ }
}
}
return true;
@@ -3433,6 +3444,7 @@ bool DependenceInfo::tryDelinearizeFixedSize(
if (!AllIndicesInRange(SrcSizes, SrcSubscripts, SrcPtr) ||
!AllIndicesInRange(DstSizes, DstSubscripts, DstPtr)) {
+ LLVM_DEBUG(dbgs() << "Check failed: AllIndicesInRange.\n");
SrcSubscripts.clear();
DstSubscripts.clear();
return false;
@@ -3500,17 +3512,27 @@ bool DependenceInfo::tryDelinearizeParametricSize(
// to the dependency checks.
if (!DisableDelinearizationChecks)
for (size_t I = 1; I < Size; ++I) {
- if (!isKnownNonNegative(SrcSubscripts[I], SrcPtr))
- return false;
-
- if (!isKnownLessThan(SrcSubscripts[I], Sizes[I - 1]))
- return false;
-
- if (!isKnownNonNegative(DstSubscripts[I], DstPtr))
- return false;
+ bool SNN = isKnownNonNegative(SrcSubscripts[I], SrcPtr);
+ bool DNN = isKnownNonNegative(DstSubscripts[I], DstPtr);
+ bool SLT = isKnownLessThan(SrcSubscripts[I], Sizes[I - 1]);
+ bool DLT = isKnownLessThan(DstSubscripts[I], Sizes[I - 1]);
+ if (SNN && DNN && SLT && DLT)
+ continue;
- if (!isKnownLessThan(DstSubscripts[I], Sizes[I - 1]))
- return false;
+ LLVM_DEBUG({
+ dbgs() << "Delinearization checks failed: can't prove the following\n";
+ if (!SNN)
+ dbgs() << " isKnownNonNegative(" << *SrcSubscripts[I] << ")\n";
+ if (!DNN)
+ dbgs() << " isKnownNonNegative(" << *DstSubscripts[I] << ")\n";
+ if (!SLT)
+ dbgs() << " isKnownLessThan(" << *SrcSubscripts[I] << ", "
+ << *Sizes[I - 1] << ")\n";
+ if (!DLT)
+ dbgs() << " isKnownLessThan(" << *DstSubscripts[I] << ", "
+ << *Sizes[I - 1] << ")\n";
+ });
+ return false;
}
return true;
|
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.
Are these new debug messages really necessary? DA already has a large number of debug messages, and I don't think they are well organized. If possible, I'd prefer not to add much more.
If other debug messages need cleaning up, that's unrelated to this change. I think it is super useful to understand why delinearization fails and so these debug messages seem useful. I will let @sebpop answer your question, but I am happy to LGTM this. |
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.
(This looks fine to me, but I also don't work on DA, so I can't comment on what's useful or not.)
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.
Personally, I don't think this is super useful, but I don't have any strong objections either.
} | ||
} | ||
return true; | ||
}; | ||
|
||
if (!AllIndicesInRange(SrcSizes, SrcSubscripts, SrcPtr) || | ||
!AllIndicesInRange(DstSizes, DstSubscripts, DstPtr)) { | ||
LLVM_DEBUG(dbgs() << "Check failed: AllIndicesInRange.\n"); |
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.
I think this is redundant.
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.
Currently, when the range check fails, the debug output looks like:
Check failed: !isKnownLessThan(S, Range)
S: {0,+,1}<nuw><nsw><%loop.j>
Range: 256
Check failed: AllIndicesInRange.
I think the last line is redundant.
if (!SNN) | ||
dbgs() << " isKnownNonNegative(" << *SrcSubscripts[I] << ")\n"; | ||
if (!DNN) | ||
dbgs() << " isKnownNonNegative(" << *DstSubscripts[I] << ")\n"; | ||
if (!SLT) | ||
dbgs() << " isKnownLessThan(" << *SrcSubscripts[I] << ", " | ||
<< *Sizes[I - 1] << ")\n"; | ||
if (!DLT) | ||
dbgs() << " isKnownLessThan(" << *DstSubscripts[I] << ", " | ||
<< *Sizes[I - 1] << ")\n"; | ||
}); |
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.
Can you unify the format? The messages in tryDelinearizeFixedSize
dump like
Check failed: !isKnownNonNegative(S, Ptr)
S: ...
Ptr: ...
But this one prints
isKnownNonNegative(..., ...)
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.
Format doesn't matter.
It's not like we're using a parser for the debug messages.
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.
I'm not talking about parsing debug outputs. The point here is to prevent an increase in messy or unorganized logging.
After posting my earlier comment, I realized that these messages should probably be placed inside isKnownNonNegative
and isKnownLessThan
, respectively.
Debug messages are supposed to tell at a glance without starting a debugger why something is discarded, etc. |
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.
This PR hasn't been approved by anyone yet. In general, you should wait for at least one approval before landing.
} | ||
} | ||
return true; | ||
}; | ||
|
||
if (!AllIndicesInRange(SrcSizes, SrcSubscripts, SrcPtr) || | ||
!AllIndicesInRange(DstSizes, DstSubscripts, DstPtr)) { | ||
LLVM_DEBUG(dbgs() << "Check failed: AllIndicesInRange.\n"); |
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.
Currently, when the range check fails, the debug output looks like:
Check failed: !isKnownLessThan(S, Range)
S: {0,+,1}<nuw><nsw><%loop.j>
Range: 256
Check failed: AllIndicesInRange.
I think the last line is redundant.
if (!SNN) | ||
dbgs() << " isKnownNonNegative(" << *SrcSubscripts[I] << ")\n"; | ||
if (!DNN) | ||
dbgs() << " isKnownNonNegative(" << *DstSubscripts[I] << ")\n"; | ||
if (!SLT) | ||
dbgs() << " isKnownLessThan(" << *SrcSubscripts[I] << ", " | ||
<< *Sizes[I - 1] << ")\n"; | ||
if (!DLT) | ||
dbgs() << " isKnownLessThan(" << *DstSubscripts[I] << ", " | ||
<< *Sizes[I - 1] << ")\n"; | ||
}); |
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.
I'm not talking about parsing debug outputs. The point here is to prevent an increase in messy or unorganized logging.
After posting my earlier comment, I realized that these messages should probably be placed inside isKnownNonNegative
and isKnownLessThan
, respectively.
No description provided.