aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/LoopAccessAnalysis.cpp
diff options
context:
space:
mode:
authorRamkumar Ramachandra <ramkumar.ramachandra@codasip.com>2025-05-21 12:01:49 +0100
committerGitHub <noreply@github.com>2025-05-21 12:01:49 +0100
commitbb2791609db5da24e51d0bc50fedff654da9a1a8 (patch)
tree2d5f75ccbedef82234c12ccd12acb9b026c13288 /llvm/lib/Analysis/LoopAccessAnalysis.cpp
parentbdc1296de4cdccfba001416f96ce42b63082220a (diff)
downloadllvm-bb2791609db5da24e51d0bc50fedff654da9a1a8.zip
llvm-bb2791609db5da24e51d0bc50fedff654da9a1a8.tar.gz
llvm-bb2791609db5da24e51d0bc50fedff654da9a1a8.tar.bz2
[LAA] Tweak debug output for UTC stability (#140764)
UpdateTestChecks has a make_analyzer_generalizer to replace pointer addressess from the debug output of LAA with a pattern, which is an acceptable solution when there is one RUN line. However, when there are multiple RUN lines with a common pattern, UTC fails to recognize common output due to mismatched pointer addresses. Instead of hacking UTC scrub the output before comparing the outputs from the different RUN lines, fix the issue once and for all by making LAA not output unstable pointer addresses in the first place. The removal of the now-dead make_analyzer_generalizer is left as a non-trivial exercise for a follow-up.
Diffstat (limited to 'llvm/lib/Analysis/LoopAccessAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/LoopAccessAnalysis.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index 2a322a6..389c3c7 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -591,20 +591,29 @@ bool RuntimePointerChecking::needsChecking(unsigned I, unsigned J) const {
return PointerI.AliasSetId == PointerJ.AliasSetId;
}
+/// Assign each RuntimeCheckingPtrGroup pointer an index for stable UTC output.
+static DenseMap<const RuntimeCheckingPtrGroup *, unsigned>
+getPtrToIdxMap(ArrayRef<RuntimeCheckingPtrGroup> CheckingGroups) {
+ DenseMap<const RuntimeCheckingPtrGroup *, unsigned> PtrIndices;
+ for (const auto &[Idx, CG] : enumerate(CheckingGroups))
+ PtrIndices[&CG] = Idx;
+ return PtrIndices;
+}
+
void RuntimePointerChecking::printChecks(
raw_ostream &OS, const SmallVectorImpl<RuntimePointerCheck> &Checks,
unsigned Depth) const {
unsigned N = 0;
+ auto PtrIndices = getPtrToIdxMap(CheckingGroups);
for (const auto &[Check1, Check2] : Checks) {
const auto &First = Check1->Members, &Second = Check2->Members;
-
OS.indent(Depth) << "Check " << N++ << ":\n";
-
- OS.indent(Depth + 2) << "Comparing group (" << Check1 << "):\n";
+ OS.indent(Depth + 2) << "Comparing group GRP" << PtrIndices.at(Check1)
+ << ":\n";
for (unsigned K : First)
OS.indent(Depth + 2) << *Pointers[K].PointerValue << "\n";
-
- OS.indent(Depth + 2) << "Against group (" << Check2 << "):\n";
+ OS.indent(Depth + 2) << "Against group GRP" << PtrIndices.at(Check2)
+ << ":\n";
for (unsigned K : Second)
OS.indent(Depth + 2) << *Pointers[K].PointerValue << "\n";
}
@@ -616,8 +625,9 @@ void RuntimePointerChecking::print(raw_ostream &OS, unsigned Depth) const {
printChecks(OS, Checks, Depth);
OS.indent(Depth) << "Grouped accesses:\n";
+ auto PtrIndices = getPtrToIdxMap(CheckingGroups);
for (const auto &CG : CheckingGroups) {
- OS.indent(Depth + 2) << "Group " << &CG << ":\n";
+ OS.indent(Depth + 2) << "Group GRP" << PtrIndices.at(&CG) << ":\n";
OS.indent(Depth + 4) << "(Low: " << *CG.Low << " High: " << *CG.High
<< ")\n";
for (unsigned Member : CG.Members) {