Skip to content

Revert #95218 and fix the build #95252

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

Closed
wants to merge 1 commit into from

Conversation

artagnon
Copy link
Contributor

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.

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

llvmbot commented Jun 12, 2024

@llvm/pr-subscribers-llvm-adt
@llvm/pr-subscribers-mlir-presburger
@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-llvm-support

Author: Ramkumar Ramachandra (artagnon)

Changes

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 --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
 

@artagnon
Copy link
Contributor Author

I'll fold this into the re-land.

@artagnon artagnon closed this Jun 12, 2024
@artagnon artagnon deleted the dynamicapint-dbgprint branch June 12, 2024 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants