[llvm] 0a25b50 - [HashRecognize] Introduce dump methods for debug (#142748)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 4 08:21:46 PDT 2025
Author: Ramkumar Ramachandra
Date: 2025-06-04T16:21:39+01:00
New Revision: 0a25b5022831c7465790cf99655afdcd0f91e34d
URL: https://github.com/llvm/llvm-project/commit/0a25b5022831c7465790cf99655afdcd0f91e34d
DIFF: https://github.com/llvm/llvm-project/commit/0a25b5022831c7465790cf99655afdcd0f91e34d.diff
LOG: [HashRecognize] Introduce dump methods for debug (#142748)
Introduce dump methods to aid interactive debugging with GDB/LLDB. While
at it, also fix the header comment in HashRecognize.cpp.
Added:
Modified:
llvm/include/llvm/Analysis/HashRecognize.h
llvm/lib/Analysis/HashRecognize.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/HashRecognize.h b/llvm/include/llvm/Analysis/HashRecognize.h
index 7a31ab681bed5..8ab68a5dc2cb1 100644
--- a/llvm/include/llvm/Analysis/HashRecognize.h
+++ b/llvm/include/llvm/Analysis/HashRecognize.h
@@ -35,6 +35,10 @@ using ErrBits = std::tuple<KnownBits, unsigned, bool>;
/// A custom std::array with 256 entries, that also has a print function.
struct CRCTable : public std::array<APInt, 256> {
void print(raw_ostream &OS) const;
+
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
+ LLVM_DUMP_METHOD void dump() const;
+#endif
};
/// The structure that is returned when a polynomial algorithm was recognized by
@@ -88,6 +92,10 @@ class HashRecognize {
CRCTable genSarwateTable(const APInt &GenPoly, bool ByteOrderSwapped) const;
void print(raw_ostream &OS) const;
+
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
+ LLVM_DUMP_METHOD void dump() const;
+#endif
};
class HashRecognizePrinterPass
diff --git a/llvm/lib/Analysis/HashRecognize.cpp b/llvm/lib/Analysis/HashRecognize.cpp
index c6e9f2b64f876..b245548dea6d5 100644
--- a/llvm/lib/Analysis/HashRecognize.cpp
+++ b/llvm/lib/Analysis/HashRecognize.cpp
@@ -1,4 +1,4 @@
-//===- HashRecognize.h ------------------------------------------*- C++ -*-===//
+//===- HashRecognize.cpp ----------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -274,7 +274,7 @@ struct RecurrenceInfo {
RecurrenceInfo(const Loop &L) : L(L) {}
operator bool() const { return BO; }
- void print(raw_ostream &OS, unsigned Indent) const {
+ void print(raw_ostream &OS, unsigned Indent = 0) const {
OS.indent(Indent) << "Phi: ";
Phi->print(OS);
OS << "\n";
@@ -294,6 +294,10 @@ struct RecurrenceInfo {
}
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
+ LLVM_DUMP_METHOD void dump() const { print(dbgs()); }
+#endif
+
bool matchSimpleRecurrence(const PHINode *P);
bool matchConditionalRecurrence(
const PHINode *P,
@@ -628,6 +632,10 @@ void CRCTable::print(raw_ostream &OS) const {
}
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
+void CRCTable::dump() const { print(dbgs()); }
+#endif
+
void HashRecognize::print(raw_ostream &OS) const {
if (!L.isInnermost())
return;
@@ -671,6 +679,10 @@ void HashRecognize::print(raw_ostream &OS) const {
genSarwateTable(Info.RHS, Info.ByteOrderSwapped).print(OS);
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
+void HashRecognize::dump() const { print(dbgs()); }
+#endif
+
HashRecognize::HashRecognize(const Loop &L, ScalarEvolution &SE)
: L(L), SE(SE) {}
More information about the llvm-commits
mailing list