[Mlir-commits] [llvm] [mlir] Revert #95218 and fix the build (PR #95252)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Jun 12 06:55:46 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-presburger
@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-llvm-support

Author: Ramkumar Ramachandra (artagnon)

<details>
<summary>Changes</summary>

Fix the build failure arising from 76030dc (mlir/Presburger/MPInt: move into llvm/ADT) by reverting the failed fix-forward #<!-- -->95218, and removing the guards on the debug-print functions in DynamicAPInt.

-- 8< --
@<!-- -->nikic has suggested a trivial fix. Of course, I can always fold this into the re-land, if a revert is really desired.

---
Full diff: https://github.com/llvm/llvm-project/pull/95252.diff


5 Files Affected:

- (modified) llvm/include/llvm/ADT/DynamicAPInt.h (-4) 
- (modified) llvm/include/llvm/ADT/SlowDynamicAPInt.h (-4) 
- (modified) llvm/lib/Support/DynamicAPInt.cpp (-2) 
- (modified) llvm/lib/Support/SlowDynamicAPInt.cpp (-2) 
- (modified) mlir/include/mlir/Analysis/Presburger/Fraction.h (+10-13) 


``````````diff
diff --git a/llvm/include/llvm/ADT/DynamicAPInt.h b/llvm/include/llvm/ADT/DynamicAPInt.h
index 78a0372e09c49..f312f776df971 100644
--- a/llvm/include/llvm/ADT/DynamicAPInt.h
+++ b/llvm/include/llvm/ADT/DynamicAPInt.h
@@ -203,18 +203,14 @@ class DynamicAPInt {
 
   friend hash_code hash_value(const DynamicAPInt &x); // NOLINT
 
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
   raw_ostream &print(raw_ostream &OS) const;
   LLVM_DUMP_METHOD void dump() const;
-#endif
 };
 
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
 inline raw_ostream &operator<<(raw_ostream &OS, const DynamicAPInt &X) {
   X.print(OS);
   return OS;
 }
-#endif
 
 /// Redeclarations of friend declaration above to
 /// make it discoverable by lookups.
diff --git a/llvm/include/llvm/ADT/SlowDynamicAPInt.h b/llvm/include/llvm/ADT/SlowDynamicAPInt.h
index 009deab6c6c92..1678bda046fec 100644
--- a/llvm/include/llvm/ADT/SlowDynamicAPInt.h
+++ b/llvm/include/llvm/ADT/SlowDynamicAPInt.h
@@ -71,18 +71,14 @@ class SlowDynamicAPInt {
 
   unsigned getBitWidth() const { return Val.getBitWidth(); }
 
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
   void print(raw_ostream &OS) const;
   LLVM_DUMP_METHOD void dump() const;
-#endif
 };
 
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
 inline raw_ostream &operator<<(raw_ostream &OS, const SlowDynamicAPInt &X) {
   X.print(OS);
   return OS;
 }
-#endif
 
 /// Returns the remainder of dividing LHS by RHS.
 ///
diff --git a/llvm/lib/Support/DynamicAPInt.cpp b/llvm/lib/Support/DynamicAPInt.cpp
index 6f7eecca36db0..cae034cf6da6f 100644
--- a/llvm/lib/Support/DynamicAPInt.cpp
+++ b/llvm/lib/Support/DynamicAPInt.cpp
@@ -18,7 +18,6 @@ hash_code llvm::hash_value(const DynamicAPInt &X) {
   return detail::hash_value(X.getLarge());
 }
 
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
 raw_ostream &DynamicAPInt::print(raw_ostream &OS) const {
   if (isSmall())
     return OS << ValSmall;
@@ -26,4 +25,3 @@ raw_ostream &DynamicAPInt::print(raw_ostream &OS) const {
 }
 
 void DynamicAPInt::dump() const { print(dbgs()); }
-#endif
diff --git a/llvm/lib/Support/SlowDynamicAPInt.cpp b/llvm/lib/Support/SlowDynamicAPInt.cpp
index 5d88cc53d17ba..7964a3d59daf5 100644
--- a/llvm/lib/Support/SlowDynamicAPInt.cpp
+++ b/llvm/lib/Support/SlowDynamicAPInt.cpp
@@ -281,8 +281,6 @@ SlowDynamicAPInt &SlowDynamicAPInt::operator--() {
 /// ---------------------------------------------------------------------------
 /// Printing.
 /// ---------------------------------------------------------------------------
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
 void SlowDynamicAPInt::print(raw_ostream &OS) const { OS << Val; }
 
 void SlowDynamicAPInt::dump() const { print(dbgs()); }
-#endif
diff --git a/mlir/include/mlir/Analysis/Presburger/Fraction.h b/mlir/include/mlir/Analysis/Presburger/Fraction.h
index 6be132058e6ca..f4f1be97147bf 100644
--- a/mlir/include/mlir/Analysis/Presburger/Fraction.h
+++ b/mlir/include/mlir/Analysis/Presburger/Fraction.h
@@ -52,23 +52,14 @@ struct Fraction {
     return num / den;
   }
 
-  /// The numerator and denominator, respectively. The denominator is always
-  /// positive.
-  DynamicAPInt num{0}, den{1};
-
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
   llvm::raw_ostream &print(llvm::raw_ostream &os) const {
     return os << "(" << num << "/" << den << ")";
   }
-#endif
-};
 
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
-inline llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const Fraction &x) {
-  x.print(os);
-  return os;
-}
-#endif
+  /// The numerator and denominator, respectively. The denominator is always
+  /// positive.
+  DynamicAPInt num{0}, den{1};
+};
 
 /// Three-way comparison between two fractions.
 /// Returns +1, 0, and -1 if the first fraction is greater than, equal to, or
@@ -165,6 +156,12 @@ inline Fraction &operator*=(Fraction &x, const Fraction &y) {
   x = x * y;
   return x;
 }
+
+inline llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const Fraction &x) {
+  x.print(os);
+  return os;
+}
+
 } // namespace presburger
 } // namespace mlir
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/95252


More information about the Mlir-commits mailing list