[llvm] 9a0e1c7 - Revert "[llvm] properly guard dump methods in Support lib classes" (#139927)
via llvm-commits
llvm-commits at lists.llvm.org
Wed May 14 09:35:22 PDT 2025
Author: Andrew Rogers
Date: 2025-05-14T09:35:19-07:00
New Revision: 9a0e1c79886ed95642b3400c0ec82f8a72d52ff6
URL: https://github.com/llvm/llvm-project/commit/9a0e1c79886ed95642b3400c0ec82f8a72d52ff6
DIFF: https://github.com/llvm/llvm-project/commit/9a0e1c79886ed95642b3400c0ec82f8a72d52ff6.diff
LOG: Revert "[llvm] properly guard dump methods in Support lib classes" (#139927)
Reverts llvm/llvm-project#139804
Added:
Modified:
llvm/include/llvm/ADT/APFixedPoint.h
llvm/include/llvm/ADT/APFloat.h
llvm/include/llvm/ADT/APInt.h
llvm/include/llvm/ADT/DynamicAPInt.h
llvm/include/llvm/ADT/SlowDynamicAPInt.h
llvm/include/llvm/ADT/TrieRawHashMap.h
llvm/include/llvm/ADT/Twine.h
llvm/include/llvm/Support/BalancedPartitioning.h
llvm/include/llvm/Support/BranchProbability.h
llvm/include/llvm/Support/DebugCounter.h
llvm/include/llvm/Support/KnownBits.h
llvm/include/llvm/Support/SMTAPI.h
llvm/include/llvm/Support/ScaledNumber.h
llvm/lib/Support/APFixedPoint.cpp
llvm/lib/Support/BalancedPartitioning.cpp
llvm/lib/Support/DebugCounter.cpp
llvm/lib/Support/DynamicAPInt.cpp
llvm/lib/Support/KnownBits.cpp
llvm/lib/Support/ScaledNumber.cpp
llvm/lib/Support/SlowDynamicAPInt.cpp
llvm/lib/Support/Z3Solver.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/APFixedPoint.h b/llvm/include/llvm/ADT/APFixedPoint.h
index 89d2a93a06a26..70d7f325702cf 100644
--- a/llvm/include/llvm/ADT/APFixedPoint.h
+++ b/llvm/include/llvm/ADT/APFixedPoint.h
@@ -249,10 +249,7 @@ class APFixedPoint {
}
void print(raw_ostream &) const;
-
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- LLVM_DUMP_METHOD void dump() const;
-#endif
+ void dump() const;
// If LHS > RHS, return 1. If LHS == RHS, return 0. If LHS < RHS, return -1.
int compare(const APFixedPoint &Other) const;
diff --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h
index b88cbc56c105c..ed49380cfc05f 100644
--- a/llvm/include/llvm/ADT/APFloat.h
+++ b/llvm/include/llvm/ADT/APFloat.h
@@ -1483,10 +1483,7 @@ class APFloat : public APFloatBase {
}
void print(raw_ostream &) const;
-
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- LLVM_DUMP_METHOD void dump() const;
-#endif
+ void dump() const;
bool getExactInverse(APFloat *inv) const {
APFLOAT_DISPATCH_ON_SEMANTICS(getExactInverse(inv));
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index 44260c7eca309..7fbf09b44e6c4 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/include/llvm/ADT/APInt.h
@@ -1896,10 +1896,8 @@ class [[nodiscard]] APInt {
/// FoldingSets.
void Profile(FoldingSetNodeID &id) const;
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
/// debug method
- LLVM_DUMP_METHOD void dump() const;
-#endif
+ void dump() const;
/// Returns whether this instance allocated memory.
bool needsCleanup() const { return !isSingleWord(); }
diff --git a/llvm/include/llvm/ADT/DynamicAPInt.h b/llvm/include/llvm/ADT/DynamicAPInt.h
index bb65a08a968d9..ff958d48e7731 100644
--- a/llvm/include/llvm/ADT/DynamicAPInt.h
+++ b/llvm/include/llvm/ADT/DynamicAPInt.h
@@ -216,9 +216,7 @@ class DynamicAPInt {
void static_assert_layout(); // NOLINT
raw_ostream &print(raw_ostream &OS) const;
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
-#endif
};
inline raw_ostream &operator<<(raw_ostream &OS, const DynamicAPInt &X) {
diff --git a/llvm/include/llvm/ADT/SlowDynamicAPInt.h b/llvm/include/llvm/ADT/SlowDynamicAPInt.h
index c9aef96b9e1c3..ec1021892cf4d 100644
--- a/llvm/include/llvm/ADT/SlowDynamicAPInt.h
+++ b/llvm/include/llvm/ADT/SlowDynamicAPInt.h
@@ -79,10 +79,7 @@ class SlowDynamicAPInt {
unsigned getBitWidth() const { return Val.getBitWidth(); }
void print(raw_ostream &OS) const;
-
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
-#endif
};
inline raw_ostream &operator<<(raw_ostream &OS, const SlowDynamicAPInt &X) {
diff --git a/llvm/include/llvm/ADT/TrieRawHashMap.h b/llvm/include/llvm/ADT/TrieRawHashMap.h
index 1382eac1c768f..e312967edeb58 100644
--- a/llvm/include/llvm/ADT/TrieRawHashMap.h
+++ b/llvm/include/llvm/ADT/TrieRawHashMap.h
@@ -90,10 +90,7 @@ class ThreadSafeTrieRawHashMapBase {
static void *operator new(size_t Size) { return ::operator new(Size); }
void operator delete(void *Ptr) { ::operator delete(Ptr); }
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
-#endif
-
void print(raw_ostream &OS) const;
protected:
@@ -217,10 +214,7 @@ class ThreadSafeTrieRawHashMap : public ThreadSafeTrieRawHashMapBase {
using ThreadSafeTrieRawHashMapBase::operator delete;
using HashType = HashT;
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
using ThreadSafeTrieRawHashMapBase::dump;
-#endif
-
using ThreadSafeTrieRawHashMapBase::print;
private:
diff --git a/llvm/include/llvm/ADT/Twine.h b/llvm/include/llvm/ADT/Twine.h
index d9e553a8a8c77..1f1fd1967efbc 100644
--- a/llvm/include/llvm/ADT/Twine.h
+++ b/llvm/include/llvm/ADT/Twine.h
@@ -507,16 +507,14 @@ namespace llvm {
/// stream \p OS.
void print(raw_ostream &OS) const;
+ /// Dump the concatenated string represented by this twine to stderr.
+ void dump() const;
+
/// Write the representation of this twine to the stream \p OS.
void printRepr(raw_ostream &OS) const;
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- /// Dump the concatenated string represented by this twine to stderr.
- LLVM_DUMP_METHOD void dump() const;
-
/// Dump the representation of this twine to stderr.
- LLVM_DUMP_METHOD void dumpRepr() const;
-#endif
+ void dumpRepr() const;
/// @}
};
diff --git a/llvm/include/llvm/Support/BalancedPartitioning.h b/llvm/include/llvm/Support/BalancedPartitioning.h
index e744a9344b2a4..05307d74c209c 100644
--- a/llvm/include/llvm/Support/BalancedPartitioning.h
+++ b/llvm/include/llvm/Support/BalancedPartitioning.h
@@ -68,9 +68,7 @@ class BPFunctionNode {
/// The ID of this node
IDT Id;
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- LLVM_DUMP_METHOD void dump(raw_ostream &OS) const;
-#endif
+ LLVM_ABI void dump(raw_ostream &OS) const;
protected:
/// The list of utility nodes associated with this node
diff --git a/llvm/include/llvm/Support/BranchProbability.h b/llvm/include/llvm/Support/BranchProbability.h
index 42fe225709ef8..570531e6b9e92 100644
--- a/llvm/include/llvm/Support/BranchProbability.h
+++ b/llvm/include/llvm/Support/BranchProbability.h
@@ -77,9 +77,7 @@ class BranchProbability {
LLVM_ABI raw_ostream &print(raw_ostream &OS) const;
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- LLVM_DUMP_METHOD void dump() const;
-#endif
+ LLVM_ABI void dump() const;
/// Scale a large integer.
///
diff --git a/llvm/include/llvm/Support/DebugCounter.h b/llvm/include/llvm/Support/DebugCounter.h
index 9611586a92c3b..529a9f86f2e34 100644
--- a/llvm/include/llvm/Support/DebugCounter.h
+++ b/llvm/include/llvm/Support/DebugCounter.h
@@ -119,10 +119,8 @@ class DebugCounter {
Counter.CurrChunkIdx = State.ChunkIdx;
}
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
// Dump or print the current counter set into llvm::dbgs().
- LLVM_DUMP_METHOD void dump() const;
-#endif
+ LLVM_ABI LLVM_DUMP_METHOD void dump() const;
LLVM_ABI void print(raw_ostream &OS) const;
diff --git a/llvm/include/llvm/Support/KnownBits.h b/llvm/include/llvm/Support/KnownBits.h
index e8dc1c2422646..6a14328d431a4 100644
--- a/llvm/include/llvm/Support/KnownBits.h
+++ b/llvm/include/llvm/Support/KnownBits.h
@@ -513,10 +513,7 @@ struct KnownBits {
bool operator!=(const KnownBits &Other) const { return !(*this == Other); }
LLVM_ABI void print(raw_ostream &OS) const;
-
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- LLVM_DUMP_METHOD void dump() const;
-#endif
+ LLVM_ABI void dump() const;
private:
// Internal helper for getting the initial KnownBits for an `srem` or `urem`
diff --git a/llvm/include/llvm/Support/SMTAPI.h b/llvm/include/llvm/Support/SMTAPI.h
index aed6241219c39..f1bb86cf81f1c 100644
--- a/llvm/include/llvm/Support/SMTAPI.h
+++ b/llvm/include/llvm/Support/SMTAPI.h
@@ -71,9 +71,7 @@ class SMTSort {
virtual void print(raw_ostream &OS) const = 0;
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- LLVM_DUMP_METHOD void dump() const;
-#endif
+ LLVM_ABI LLVM_DUMP_METHOD void dump() const;
protected:
/// Query the SMT solver and returns true if two sorts are equal (same kind
@@ -120,9 +118,7 @@ class SMTExpr {
virtual void print(raw_ostream &OS) const = 0;
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- LLVM_DUMP_METHOD void dump() const;
-#endif
+ LLVM_ABI LLVM_DUMP_METHOD void dump() const;
protected:
/// Query the SMT solver and returns true if two sorts are equal (same kind
@@ -140,9 +136,7 @@ class SMTSolverStatistics {
virtual void print(raw_ostream &OS) const = 0;
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- LLVM_DUMP_METHOD void dump() const;
-#endif
+ LLVM_ABI LLVM_DUMP_METHOD void dump() const;
};
/// Shared pointer for SMTExprs, used by SMTSolver API.
@@ -158,9 +152,7 @@ class SMTSolver {
SMTSolver() = default;
virtual ~SMTSolver() = default;
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- LLVM_DUMP_METHOD void dump() const;
-#endif
+ LLVM_ABI LLVM_DUMP_METHOD void dump() const;
// Returns an appropriate floating-point sort for the given bitwidth.
SMTSortRef getFloatSort(unsigned BitWidth) {
diff --git a/llvm/include/llvm/Support/ScaledNumber.h b/llvm/include/llvm/Support/ScaledNumber.h
index 3d38677f0eb61..87a56809976a3 100644
--- a/llvm/include/llvm/Support/ScaledNumber.h
+++ b/llvm/include/llvm/Support/ScaledNumber.h
@@ -424,10 +424,7 @@ class ScaledNumberBase {
public:
static constexpr int DefaultPrecision = 10;
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- LLVM_DUMP_METHOD static void dump(uint64_t D, int16_t E, int Width);
-#endif
-
+ LLVM_ABI static void dump(uint64_t D, int16_t E, int Width);
LLVM_ABI static raw_ostream &print(raw_ostream &OS, uint64_t D, int16_t E,
int Width, unsigned Precision);
LLVM_ABI static std::string toString(uint64_t D, int16_t E, int Width,
@@ -610,12 +607,7 @@ template <class DigitsT> class ScaledNumber : ScaledNumberBase {
unsigned Precision = DefaultPrecision) const {
return ScaledNumberBase::print(OS, Digits, Scale, Width, Precision);
}
-
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- LLVM_DUMP_METHOD void dump() const {
- return ScaledNumberBase::dump(Digits, Scale, Width);
- }
-#endif
+ void dump() const { return ScaledNumberBase::dump(Digits, Scale, Width); }
ScaledNumber &operator+=(const ScaledNumber &X) {
std::tie(Digits, Scale) =
diff --git a/llvm/lib/Support/APFixedPoint.cpp b/llvm/lib/Support/APFixedPoint.cpp
index 9a7caa4112625..f395919287b72 100644
--- a/llvm/lib/Support/APFixedPoint.cpp
+++ b/llvm/lib/Support/APFixedPoint.cpp
@@ -439,10 +439,7 @@ void APFixedPoint::print(raw_ostream &OS) const {
Sema.print(OS);
OS << "})";
}
-
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void APFixedPoint::dump() const { print(llvm::errs()); }
-#endif
APFixedPoint APFixedPoint::negate(bool *Overflow) const {
if (!isSaturated()) {
diff --git a/llvm/lib/Support/BalancedPartitioning.cpp b/llvm/lib/Support/BalancedPartitioning.cpp
index b185ef86cd29e..ed3b149c03daf 100644
--- a/llvm/lib/Support/BalancedPartitioning.cpp
+++ b/llvm/lib/Support/BalancedPartitioning.cpp
@@ -21,12 +21,10 @@
using namespace llvm;
#define DEBUG_TYPE "balanced-partitioning"
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
-LLVM_DUMP_METHOD void BPFunctionNode::dump(raw_ostream &OS) const {
+void BPFunctionNode::dump(raw_ostream &OS) const {
OS << formatv("{{ID={0} Utilities={{{1:$[,]}} Bucket={2}}", Id,
make_range(UtilityNodes.begin(), UtilityNodes.end()), Bucket);
}
-#endif
template <typename Func>
void BalancedPartitioning::BPThreadPool::async(Func &&F) {
diff --git a/llvm/lib/Support/DebugCounter.cpp b/llvm/lib/Support/DebugCounter.cpp
index 9c4a4429ca0ee..a6de07a55482a 100644
--- a/llvm/lib/Support/DebugCounter.cpp
+++ b/llvm/lib/Support/DebugCounter.cpp
@@ -248,8 +248,6 @@ bool DebugCounter::shouldExecuteImpl(unsigned CounterName) {
return true;
}
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void DebugCounter::dump() const {
print(dbgs());
}
-#endif
diff --git a/llvm/lib/Support/DynamicAPInt.cpp b/llvm/lib/Support/DynamicAPInt.cpp
index 9def5c782af4c..bfcb97e0cc96a 100644
--- a/llvm/lib/Support/DynamicAPInt.cpp
+++ b/llvm/lib/Support/DynamicAPInt.cpp
@@ -32,6 +32,4 @@ raw_ostream &DynamicAPInt::print(raw_ostream &OS) const {
return OS << ValLarge;
}
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
-LLVM_DUMP_METHOD void DynamicAPInt::dump() const { print(dbgs()); }
-#endif
+void DynamicAPInt::dump() const { print(dbgs()); }
diff --git a/llvm/lib/Support/KnownBits.cpp b/llvm/lib/Support/KnownBits.cpp
index 94a04ab90987a..16229598b612a 100644
--- a/llvm/lib/Support/KnownBits.cpp
+++ b/llvm/lib/Support/KnownBits.cpp
@@ -1152,10 +1152,7 @@ void KnownBits::print(raw_ostream &OS) const {
OS << "?";
}
}
-
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
-LLVM_DUMP_METHOD void KnownBits::dump() const {
+void KnownBits::dump() const {
print(dbgs());
dbgs() << "\n";
}
-#endif
diff --git a/llvm/lib/Support/ScaledNumber.cpp b/llvm/lib/Support/ScaledNumber.cpp
index 33e8cc3030873..85d7afbea5c69 100644
--- a/llvm/lib/Support/ScaledNumber.cpp
+++ b/llvm/lib/Support/ScaledNumber.cpp
@@ -317,9 +317,7 @@ raw_ostream &ScaledNumberBase::print(raw_ostream &OS, uint64_t D, int16_t E,
return OS << toString(D, E, Width, Precision);
}
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
-LLVM_DUMP_METHOD void ScaledNumberBase::dump(uint64_t D, int16_t E, int Width) {
+void ScaledNumberBase::dump(uint64_t D, int16_t E, int Width) {
print(dbgs(), D, E, Width, 0) << "[" << Width << ":" << D << "*2^" << E
<< "]";
}
-#endif
diff --git a/llvm/lib/Support/SlowDynamicAPInt.cpp b/llvm/lib/Support/SlowDynamicAPInt.cpp
index a57fec2f824e1..8b4030ddf9fc4 100644
--- a/llvm/lib/Support/SlowDynamicAPInt.cpp
+++ b/llvm/lib/Support/SlowDynamicAPInt.cpp
@@ -283,6 +283,4 @@ SlowDynamicAPInt &SlowDynamicAPInt::operator--() {
/// ---------------------------------------------------------------------------
void SlowDynamicAPInt::print(raw_ostream &OS) const { OS << Val; }
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
-LLVM_DUMP_METHOD void SlowDynamicAPInt::dump() const { print(dbgs()); }
-#endif
+void SlowDynamicAPInt::dump() const { print(dbgs()); }
diff --git a/llvm/lib/Support/Z3Solver.cpp b/llvm/lib/Support/Z3Solver.cpp
index 27027093a0c6f..9aece099b0629 100644
--- a/llvm/lib/Support/Z3Solver.cpp
+++ b/llvm/lib/Support/Z3Solver.cpp
@@ -989,9 +989,7 @@ llvm::SMTSolverRef llvm::CreateZ3Solver() {
#endif
}
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void SMTSort::dump() const { print(llvm::errs()); }
LLVM_DUMP_METHOD void SMTExpr::dump() const { print(llvm::errs()); }
LLVM_DUMP_METHOD void SMTSolver::dump() const { print(llvm::errs()); }
LLVM_DUMP_METHOD void SMTSolverStatistics::dump() const { print(llvm::errs()); }
-#endif
More information about the llvm-commits
mailing list