[Mlir-commits] [flang] [mlir] [mlir] Mark dump() methods with LLVM_DUMP_METHOD (PR #233398)
Andrei Golubev
llvmlistbot at llvm.org
Thu Oct 22 01:17:35 PDT 2026
https://github.com/andrey-golubev updated https://github.com/llvm/llvm-project/pull/233398
>From 33ac477aa4b0a0e77b14ae56f901e544029797ef Mon Sep 17 00:00:00 2001
From: "Golubev, Andrey" <andrey.golubev at intel.com>
Date: Mon, 19 Oct 2026 10:16:26 +0000
Subject: [PATCH 1/3] [NFC][mlir] Mark dump() methods with LLVM_DUMP_METHOD
LLVM_DUMP_METHOD is a macro that helps to prevent symbol elimination
from the binary. This is particularly useful to preserve "debug" methods
such as dump() in order to use them during debugging sessions. In
practice, user builds might even force stripping of "unused symbols" and
dead code via compiler/linker flags. Yet, ::dump() methods seem to be
useful even when that stripping is enabled for debug builds.
As an example, a local build with stripping, running under lldb would
result in the following when evaluating stripped
mlir::Operation::dump():
```
expr op->dump()
note: Ran expression as 'C++14'.
error: Couldn't look up symbols:
$__lldb_func::0x1e:0x400b1f000002d037:_ZN4mlir9Operation4dumpEv
Hint: The expression tried to call a function that is not present in the target, perhaps because it was optimized out by the compiler.
```
As there's also mlir::Operation::dumpPretty() that is marked with
LLVM_DUMP_METHOD, in the same session, at the same breakpoint the result
for a non-stripped method is:
```
expr op->dumpPretty()
func.func @main(%arg0: tensor<?x?x?x1xf32>) -> tensor<?x1x?x?xf32> {
...
```
that is, non-stripped methods can successfully be called, despite
compiler flags / build configuration.
Thus, mark MLIR-related dump() methods with the macro so that they are
not stripped away (in Debug or when LLVM_ENABLE_DUMP is defined).
Note: LLVM's documentation suggests to additionally cover methods marked
with LLVM_DUMP_METHOD by an #ifdef so that they are still properly
stripped in the Release builds. However, mlir::Operation::dumpPretty()
is not covered by that. Given that the macro itself resolves into "no
inline" in case of Release, it seems it should already be sufficient. At
least without an additional wrapping the behaviour seems to be
more-or-less exact to the original one when the macro was not used.
---
mlir/include/mlir/Analysis/CallGraph.h | 2 +-
mlir/include/mlir/Analysis/Liveness.h | 2 +-
mlir/include/mlir/Analysis/Presburger/IntegerRelation.h | 2 +-
mlir/include/mlir/Analysis/Presburger/Matrix.h | 2 +-
mlir/include/mlir/Analysis/Presburger/PWMAFunction.h | 4 ++--
mlir/include/mlir/Analysis/Presburger/PresburgerRelation.h | 2 +-
mlir/include/mlir/Analysis/Presburger/PresburgerSpace.h | 4 ++--
mlir/include/mlir/Analysis/Presburger/Simplex.h | 2 +-
mlir/include/mlir/Analysis/Presburger/Utils.h | 2 +-
mlir/include/mlir/Debug/ExecutionContext.h | 5 +----
mlir/include/mlir/Dialect/Affine/Analysis/Utils.h | 4 ++--
mlir/include/mlir/IR/AffineExpr.h | 2 +-
mlir/include/mlir/IR/AffineMap.h | 2 +-
mlir/include/mlir/IR/Attributes.h | 2 +-
mlir/include/mlir/IR/Block.h | 2 +-
mlir/include/mlir/IR/IntegerSet.h | 2 +-
mlir/include/mlir/IR/Location.h | 2 +-
mlir/include/mlir/IR/OpDefinition.h | 2 +-
mlir/include/mlir/IR/Operation.h | 2 +-
mlir/include/mlir/IR/OperationSupport.h | 2 +-
mlir/include/mlir/IR/Types.h | 2 +-
mlir/include/mlir/IR/Value.h | 2 +-
mlir/include/mlir/Interfaces/InferTypeOpInterface.h | 2 +-
mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h | 2 +-
mlir/include/mlir/Pass/PassManager.h | 2 +-
mlir/lib/Debug/ExecutionContext.cpp | 5 +++++
mlir/lib/Dialect/SparseTensor/IR/Detail/Var.h | 2 +-
27 files changed, 34 insertions(+), 32 deletions(-)
diff --git a/mlir/include/mlir/Analysis/CallGraph.h b/mlir/include/mlir/Analysis/CallGraph.h
index 9808aea1239cfb..fc342255c5ca1f 100644
--- a/mlir/include/mlir/Analysis/CallGraph.h
+++ b/mlir/include/mlir/Analysis/CallGraph.h
@@ -208,7 +208,7 @@ class CallGraph {
iterator end() const { return nodes.end(); }
/// Dump the graph in a human readable format.
- void dump() const;
+ LLVM_DUMP_METHOD void dump() const;
void print(raw_ostream &os) const;
private:
diff --git a/mlir/include/mlir/Analysis/Liveness.h b/mlir/include/mlir/Analysis/Liveness.h
index ca4d8dfab3c919..23d9543a1af43b 100644
--- a/mlir/include/mlir/Analysis/Liveness.h
+++ b/mlir/include/mlir/Analysis/Liveness.h
@@ -78,7 +78,7 @@ class Liveness {
bool isDeadAfter(Value value, Operation *operation) const;
/// Dumps the liveness information in a human readable format.
- void dump() const;
+ LLVM_DUMP_METHOD void dump() const;
/// Dumps the liveness information to the given stream.
void print(raw_ostream &os) const;
diff --git a/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h b/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h
index 4b13085eceddfc..ce6e9df1540774 100644
--- a/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h
+++ b/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h
@@ -849,7 +849,7 @@ class IntegerRelation {
bool isFullDim();
void print(raw_ostream &os) const;
- void dump() const;
+ LLVM_DUMP_METHOD void dump() const;
protected:
/// Checks all rows of equality/inequality constraints for trivial
diff --git a/mlir/include/mlir/Analysis/Presburger/Matrix.h b/mlir/include/mlir/Analysis/Presburger/Matrix.h
index 96afef1bd3105f..3c034043c419d3 100644
--- a/mlir/include/mlir/Analysis/Presburger/Matrix.h
+++ b/mlir/include/mlir/Analysis/Presburger/Matrix.h
@@ -210,7 +210,7 @@ class Matrix {
/// Print the matrix.
void print(raw_ostream &os) const;
- void dump() const;
+ LLVM_DUMP_METHOD void dump() const;
/// Return whether the Matrix is in a consistent state with all its
/// invariants satisfied.
diff --git a/mlir/include/mlir/Analysis/Presburger/PWMAFunction.h b/mlir/include/mlir/Analysis/Presburger/PWMAFunction.h
index fcc39bf0e0537d..e7a3e271673bfa 100644
--- a/mlir/include/mlir/Analysis/Presburger/PWMAFunction.h
+++ b/mlir/include/mlir/Analysis/Presburger/PWMAFunction.h
@@ -110,7 +110,7 @@ class MultiAffineFunction {
IntegerRelation getAsRelation() const;
void print(raw_ostream &os) const;
- void dump() const;
+ LLVM_DUMP_METHOD void dump() const;
private:
/// Assert that the MAF is consistent.
@@ -221,7 +221,7 @@ class PWMAFunction {
PWMAFunction unionLexMax(const PWMAFunction &func);
void print(raw_ostream &os) const;
- void dump() const;
+ LLVM_DUMP_METHOD void dump() const;
private:
/// Return a function defined on the union of the domains of `this` and
diff --git a/mlir/include/mlir/Analysis/Presburger/PresburgerRelation.h b/mlir/include/mlir/Analysis/Presburger/PresburgerRelation.h
index f7e06a6b22a95d..778f99d9414ff5 100644
--- a/mlir/include/mlir/Analysis/Presburger/PresburgerRelation.h
+++ b/mlir/include/mlir/Analysis/Presburger/PresburgerRelation.h
@@ -223,7 +223,7 @@ class PresburgerRelation {
/// Print the set's internal state.
void print(raw_ostream &os) const;
- void dump() const;
+ LLVM_DUMP_METHOD void dump() const;
protected:
/// Construct an empty PresburgerRelation with the specified number of
diff --git a/mlir/include/mlir/Analysis/Presburger/PresburgerSpace.h b/mlir/include/mlir/Analysis/Presburger/PresburgerSpace.h
index c7808e72014706..ede6f4279fe90e 100644
--- a/mlir/include/mlir/Analysis/Presburger/PresburgerSpace.h
+++ b/mlir/include/mlir/Analysis/Presburger/PresburgerSpace.h
@@ -102,7 +102,7 @@ class Identifier {
bool operator!=(const Identifier &other) const { return !isEqual(other); }
void print(llvm::raw_ostream &os) const;
- void dump() const;
+ LLVM_DUMP_METHOD void dump() const;
private:
/// The value of the identifier.
@@ -311,7 +311,7 @@ class PresburgerSpace {
void mergeAndAlignSymbols(PresburgerSpace &other);
void print(llvm::raw_ostream &os) const;
- void dump() const;
+ LLVM_DUMP_METHOD void dump() const;
protected:
PresburgerSpace(unsigned numDomain, unsigned numRange, unsigned numSymbols,
diff --git a/mlir/include/mlir/Analysis/Presburger/Simplex.h b/mlir/include/mlir/Analysis/Presburger/Simplex.h
index d89bbe37a6b3e0..163ae249752530 100644
--- a/mlir/include/mlir/Analysis/Presburger/Simplex.h
+++ b/mlir/include/mlir/Analysis/Presburger/Simplex.h
@@ -205,7 +205,7 @@ class SimplexBase {
/// Print the tableau's internal state.
void print(raw_ostream &os) const;
- void dump() const;
+ LLVM_DUMP_METHOD void dump() const;
protected:
/// Construct a SimplexBase with the specified number of variables and fixed
diff --git a/mlir/include/mlir/Analysis/Presburger/Utils.h b/mlir/include/mlir/Analysis/Presburger/Utils.h
index 0e6d18279d67ed..a4083a9eb20550 100644
--- a/mlir/include/mlir/Analysis/Presburger/Utils.h
+++ b/mlir/include/mlir/Analysis/Presburger/Utils.h
@@ -182,7 +182,7 @@ class DivisionRepr {
removeDuplicateDivs(llvm::function_ref<bool(unsigned i, unsigned j)> merge);
void print(raw_ostream &os) const;
- void dump() const;
+ LLVM_DUMP_METHOD void dump() const;
private:
/// Each row of the Matrix represents a single division dividend. The
diff --git a/mlir/include/mlir/Debug/ExecutionContext.h b/mlir/include/mlir/Debug/ExecutionContext.h
index 93c26e0ce5f82f..e2a5f3d0f32697 100644
--- a/mlir/include/mlir/Debug/ExecutionContext.h
+++ b/mlir/include/mlir/Debug/ExecutionContext.h
@@ -29,10 +29,7 @@ struct ActionActiveStack {
const Action &getAction() const { return action; }
int getDepth() const { return depth; }
void print(raw_ostream &os, bool withContext) const;
- void dump() const {
- print(llvm::errs(), /*withContext=*/true);
- llvm::errs() << "\n";
- }
+ LLVM_DUMP_METHOD void dump() const;
Breakpoint *getBreakpoint() const { return breakpoint; }
void setBreakpoint(Breakpoint *breakpoint) { this->breakpoint = breakpoint; }
diff --git a/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h b/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h
index df4145db90a616..5365e381856f71 100644
--- a/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h
+++ b/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h
@@ -264,7 +264,7 @@ struct MemRefDependenceGraph {
void print(raw_ostream &os) const;
- void dump() const { print(llvm::errs()); }
+ LLVM_DUMP_METHOD void dump() const { print(llvm::errs()); }
/// The block for which this graph is created to perform fusion.
Block █
@@ -372,7 +372,7 @@ struct ComputationSliceState {
/// If the validity cannot be determined, returns std::nullopt.
std::optional<bool> isSliceValid() const;
- void dump() const;
+ LLVM_DUMP_METHOD void dump() const;
private:
/// Fast check to determine if the computation slice is maximal. Returns true
diff --git a/mlir/include/mlir/IR/AffineExpr.h b/mlir/include/mlir/IR/AffineExpr.h
index 51b5e972abd41c..3f26afe5e0856f 100644
--- a/mlir/include/mlir/IR/AffineExpr.h
+++ b/mlir/include/mlir/IR/AffineExpr.h
@@ -87,7 +87,7 @@ class AffineExpr {
AffineExprKind getKind() const;
void print(raw_ostream &os) const;
- void dump() const;
+ LLVM_DUMP_METHOD void dump() const;
/// Returns true if this expression is made out of only symbols and
/// constants, i.e., it does not involve dimensional identifiers.
diff --git a/mlir/include/mlir/IR/AffineMap.h b/mlir/include/mlir/IR/AffineMap.h
index aa932e7bcda6c6..98792775c23cfa 100644
--- a/mlir/include/mlir/IR/AffineMap.h
+++ b/mlir/include/mlir/IR/AffineMap.h
@@ -198,7 +198,7 @@ class AffineMap {
// Prints affine map to 'os'.
void print(raw_ostream &os) const;
- void dump() const;
+ LLVM_DUMP_METHOD void dump() const;
unsigned getNumDims() const;
unsigned getNumSymbols() const;
diff --git a/mlir/include/mlir/IR/Attributes.h b/mlir/include/mlir/IR/Attributes.h
index a2f9c5fcda873f..389ba95d9be971 100644
--- a/mlir/include/mlir/IR/Attributes.h
+++ b/mlir/include/mlir/IR/Attributes.h
@@ -63,7 +63,7 @@ class Attribute {
/// without a trailing colon type if it has one.
void print(raw_ostream &os, bool elideType = false) const;
void print(raw_ostream &os, AsmState &state, bool elideType = false) const;
- void dump() const;
+ LLVM_DUMP_METHOD void dump() const;
/// Print the attribute without dialect wrapping.
void printStripped(raw_ostream &os) const;
diff --git a/mlir/include/mlir/IR/Block.h b/mlir/include/mlir/IR/Block.h
index 3638595358e254..7611f5320c82b1 100644
--- a/mlir/include/mlir/IR/Block.h
+++ b/mlir/include/mlir/IR/Block.h
@@ -406,7 +406,7 @@ class alignas(8) Block : public IRObjectWithUseList<BlockOperand>,
void print(raw_ostream &os);
void print(raw_ostream &os, AsmState &state);
- void dump();
+ LLVM_DUMP_METHOD void dump();
/// Print out the name of the block without printing its body.
/// NOTE: The printType argument is ignored. We keep it for compatibility
diff --git a/mlir/include/mlir/IR/IntegerSet.h b/mlir/include/mlir/IR/IntegerSet.h
index 3c84131e8ecd5a..088a4ca42da242 100644
--- a/mlir/include/mlir/IR/IntegerSet.h
+++ b/mlir/include/mlir/IR/IntegerSet.h
@@ -103,7 +103,7 @@ class IntegerSet {
void walkExprs(function_ref<void(AffineExpr)> callback) const;
void print(raw_ostream &os) const;
- void dump() const;
+ LLVM_DUMP_METHOD void dump() const;
friend ::llvm::hash_code hash_value(IntegerSet arg);
diff --git a/mlir/include/mlir/IR/Location.h b/mlir/include/mlir/IR/Location.h
index abc435b9b08ff2..a8f458343b701d 100644
--- a/mlir/include/mlir/IR/Location.h
+++ b/mlir/include/mlir/IR/Location.h
@@ -95,7 +95,7 @@ class Location {
/// Print the location.
void print(raw_ostream &os) const { impl.print(os); }
- void dump() const { impl.dump(); }
+ LLVM_DUMP_METHOD void dump() const { impl.dump(); }
friend ::llvm::hash_code hash_value(Location arg);
diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h
index 38cd7da8495e19..15bbe5730c3e27 100644
--- a/mlir/include/mlir/IR/OpDefinition.h
+++ b/mlir/include/mlir/IR/OpDefinition.h
@@ -123,7 +123,7 @@ class OpState {
}
/// Dump this operation.
- void dump() { state->dump(); }
+ LLVM_DUMP_METHOD void dump() { state->dump(); }
/// The source location the operation was defined or derived from.
Location getLoc() { return state->getLoc(); }
diff --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h
index 3ea9ad8ca0cfc4..adddd8572f2a3c 100644
--- a/mlir/include/mlir/IR/Operation.h
+++ b/mlir/include/mlir/IR/Operation.h
@@ -345,7 +345,7 @@ class alignas(8) Operation final
void print(raw_ostream &os, const OpPrintingFlags &flags = {});
void print(raw_ostream &os, AsmState &state);
- void dump();
+ LLVM_DUMP_METHOD void dump();
// Dump pretty printed IR. This method is helpful for better readability if
// the Operation is not verified because it won't disable custom printers to
diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h
index 3b43a1cf07bf99..68be626d7a560b 100644
--- a/mlir/include/mlir/IR/OperationSupport.h
+++ b/mlir/include/mlir/IR/OperationSupport.h
@@ -541,7 +541,7 @@ class OperationName {
StringAttr getIdentifier() const { return getImpl()->getName(); }
void print(raw_ostream &os) const;
- void dump() const;
+ LLVM_DUMP_METHOD void dump() const;
/// Represent the operation name as an opaque pointer. (Used to support
/// PointerLikeTypeTraits).
diff --git a/mlir/include/mlir/IR/Types.h b/mlir/include/mlir/IR/Types.h
index 70599b448f76e6..89c93cf0687bf3 100644
--- a/mlir/include/mlir/IR/Types.h
+++ b/mlir/include/mlir/IR/Types.h
@@ -159,7 +159,7 @@ class Type {
/// Print the current type.
void print(raw_ostream &os) const;
void print(raw_ostream &os, AsmState &state) const;
- void dump() const;
+ LLVM_DUMP_METHOD void dump() const;
friend ::llvm::hash_code hash_value(Type arg);
diff --git a/mlir/include/mlir/IR/Value.h b/mlir/include/mlir/IR/Value.h
index a34837bfcea1ad..d5cef1f0c44ba3 100644
--- a/mlir/include/mlir/IR/Value.h
+++ b/mlir/include/mlir/IR/Value.h
@@ -223,7 +223,7 @@ class Value {
void print(raw_ostream &os) const;
void print(raw_ostream &os, const OpPrintingFlags &flags) const;
void print(raw_ostream &os, AsmState &state) const;
- void dump() const;
+ LLVM_DUMP_METHOD void dump() const;
/// Print this value as if it were an operand.
void printAsOperand(raw_ostream &os, AsmState &state) const;
diff --git a/mlir/include/mlir/Interfaces/InferTypeOpInterface.h b/mlir/include/mlir/Interfaces/InferTypeOpInterface.h
index 1bfb66e681d8da..90ce18aad0cb03 100644
--- a/mlir/include/mlir/Interfaces/InferTypeOpInterface.h
+++ b/mlir/include/mlir/Interfaces/InferTypeOpInterface.h
@@ -92,7 +92,7 @@ class ShapeAdaptor {
explicit operator bool() const { return !val.isNull(); }
/// Dumps textual repesentation to stderr.
- void dump() const;
+ LLVM_DUMP_METHOD void dump() const;
private:
// Union storing either ShapedTypeComponents, ShapedType (stored as Type and
diff --git a/mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h b/mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h
index 50c2dfe64de2bb..593d4398a4f7ec 100644
--- a/mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h
+++ b/mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h
@@ -353,7 +353,7 @@ class ValueBoundsConstraintSet
/// Debugging only: Dump the constraint set and the column-to-value/dim
/// mapping to llvm::errs.
- void dump() const;
+ LLVM_DUMP_METHOD void dump() const;
protected:
/// Dimension identifier to indicate a value is index-typed. This is used for
diff --git a/mlir/include/mlir/Pass/PassManager.h b/mlir/include/mlir/Pass/PassManager.h
index 0f2a2bd060acd0..a3ff667940a322 100644
--- a/mlir/include/mlir/Pass/PassManager.h
+++ b/mlir/include/mlir/Pass/PassManager.h
@@ -148,7 +148,7 @@ class OpPassManager {
void printAsTextualPipeline(raw_ostream &os, bool pretty = false) const;
/// Raw dump of the pass manager to llvm::errs().
- void dump();
+ LLVM_DUMP_METHOD void dump();
/// Merge the pass statistics of this class into 'other'.
void mergeStatisticsInto(OpPassManager &other);
diff --git a/mlir/lib/Debug/ExecutionContext.cpp b/mlir/lib/Debug/ExecutionContext.cpp
index cc72bac549ab02..1fd38349b0f5d9 100644
--- a/mlir/lib/Debug/ExecutionContext.cpp
+++ b/mlir/lib/Debug/ExecutionContext.cpp
@@ -42,6 +42,11 @@ void ActionActiveStack::print(raw_ostream &os, bool withContext) const {
}
}
+void ActionActiveStack::dump() const {
+ print(llvm::errs(), /*withContext=*/true);
+ llvm::errs() << "\n";
+}
+
//===----------------------------------------------------------------------===//
// ExecutionContext
//===----------------------------------------------------------------------===//
diff --git a/mlir/lib/Dialect/SparseTensor/IR/Detail/Var.h b/mlir/lib/Dialect/SparseTensor/IR/Detail/Var.h
index dce8b003b013bb..36e4785d5efd95 100644
--- a/mlir/lib/Dialect/SparseTensor/IR/Detail/Var.h
+++ b/mlir/lib/Dialect/SparseTensor/IR/Detail/Var.h
@@ -134,7 +134,7 @@ class Var {
std::string str() const;
void print(llvm::raw_ostream &os) const;
void print(AsmPrinter &printer) const;
- void dump() const;
+ LLVM_DUMP_METHOD void dump() const;
};
static_assert(IsZeroCostAbstraction<Var>);
>From 8a211da51248fc4718c5c7aeb81e21f2dfbd2f83 Mon Sep 17 00:00:00 2001
From: "Golubev, Andrey" <andrey.golubev at intel.com>
Date: Mon, 19 Oct 2026 11:57:05 +0000
Subject: [PATCH 2/3] Wrap dump methods into #ifdef to remove them in Release
builds
Replace ::dump() calls in non-debug callers with ::print() to avoid
compiler / linker errors in Release builds due to now missing dump()
methods.
---
.../flang/Optimizer/Builder/FIRBuilder.h | 2 ++
flang/lib/Optimizer/Builder/FIRBuilder.cpp | 2 ++
flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 3 ++-
mlir/examples/toy/Ch2/toyc.cpp | 6 ++++--
mlir/examples/toy/Ch3/toyc.cpp | 3 ++-
mlir/examples/toy/Ch4/toyc.cpp | 3 ++-
mlir/examples/toy/Ch5/toyc.cpp | 3 ++-
mlir/examples/toy/Ch6/toyc.cpp | 3 ++-
mlir/examples/toy/Ch7/toyc.cpp | 3 ++-
.../transform-opt/mlir-transform-opt.cpp | 6 ++++--
mlir/include/mlir/Analysis/CallGraph.h | 2 ++
mlir/include/mlir/Analysis/Liveness.h | 2 ++
.../Analysis/Presburger/IntegerRelation.h | 2 ++
.../include/mlir/Analysis/Presburger/Matrix.h | 2 ++
.../mlir/Analysis/Presburger/PWMAFunction.h | 4 ++++
.../Analysis/Presburger/PresburgerRelation.h | 2 ++
.../Analysis/Presburger/PresburgerSpace.h | 4 ++++
.../mlir/Analysis/Presburger/Simplex.h | 2 ++
mlir/include/mlir/Analysis/Presburger/Utils.h | 2 ++
mlir/include/mlir/Debug/ExecutionContext.h | 2 ++
.../mlir/Dialect/Affine/Analysis/Utils.h | 4 ++++
mlir/include/mlir/IR/AffineExpr.h | 2 ++
mlir/include/mlir/IR/AffineMap.h | 2 ++
mlir/include/mlir/IR/Attributes.h | 2 ++
mlir/include/mlir/IR/Block.h | 2 ++
mlir/include/mlir/IR/IntegerSet.h | 2 ++
mlir/include/mlir/IR/Location.h | 2 ++
mlir/include/mlir/IR/OpDefinition.h | 2 ++
mlir/include/mlir/IR/Operation.h | 2 ++
mlir/include/mlir/IR/OperationSupport.h | 2 ++
mlir/include/mlir/IR/Types.h | 2 ++
mlir/include/mlir/IR/Value.h | 2 ++
.../mlir/Interfaces/InferTypeOpInterface.h | 2 ++
.../mlir/Interfaces/ValueBoundsOpInterface.h | 2 ++
mlir/include/mlir/Pass/PassManager.h | 2 ++
mlir/lib/Analysis/CallGraph.cpp | 2 ++
mlir/lib/Analysis/Liveness.cpp | 2 ++
.../Analysis/Presburger/IntegerRelation.cpp | 2 ++
mlir/lib/Analysis/Presburger/Matrix.cpp | 2 ++
mlir/lib/Analysis/Presburger/PWMAFunction.cpp | 4 ++++
.../Presburger/PresburgerRelation.cpp | 2 ++
.../Analysis/Presburger/PresburgerSpace.cpp | 4 ++++
mlir/lib/Analysis/Presburger/Simplex.cpp | 2 ++
mlir/lib/Analysis/Presburger/Utils.cpp | 2 ++
mlir/lib/CAPI/IR/AffineExpr.cpp | 3 ++-
mlir/lib/CAPI/IR/AffineMap.cpp | 5 ++++-
mlir/lib/CAPI/IR/IR.cpp | 20 +++++++++++++++----
mlir/lib/CAPI/IR/IntegerSet.cpp | 5 ++++-
mlir/lib/Conversion/SPIRVCommon/Pattern.h | 3 ++-
mlir/lib/Debug/ExecutionContext.cpp | 2 ++
mlir/lib/Dialect/Affine/Analysis/Utils.cpp | 2 ++
.../Dialect/SparseTensor/IR/Detail/Var.cpp | 2 ++
mlir/lib/Dialect/SparseTensor/IR/Detail/Var.h | 2 ++
mlir/lib/IR/AsmPrinter.cpp | 14 +++++++++++++
mlir/lib/Interfaces/InferTypeOpInterface.cpp | 2 ++
.../lib/Interfaces/ValueBoundsOpInterface.cpp | 2 ++
mlir/lib/Pass/Pass.cpp | 2 ++
mlir/lib/Tools/mlir-opt/MlirOptMain.cpp | 6 +++---
mlir/lib/Transforms/PrintIR.cpp | 3 ++-
.../Presburger/LinearTransformTest.cpp | 2 +-
60 files changed, 164 insertions(+), 23 deletions(-)
diff --git a/flang/include/flang/Optimizer/Builder/FIRBuilder.h b/flang/include/flang/Optimizer/Builder/FIRBuilder.h
index 3857d2b73c4ee1..e66acb443e51d3 100644
--- a/flang/include/flang/Optimizer/Builder/FIRBuilder.h
+++ b/flang/include/flang/Optimizer/Builder/FIRBuilder.h
@@ -687,8 +687,10 @@ class FirOpBuilder : public mlir::OpBuilder, public mlir::OpBuilder::Listener {
return fpMaxminBehavior;
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
/// Dump the current function. (debug)
LLVM_DUMP_METHOD void dumpFunc();
+#endif
/// FirOpBuilder hook for creating new operation.
void notifyOperationInserted(mlir::Operation *op,
diff --git a/flang/lib/Optimizer/Builder/FIRBuilder.cpp b/flang/lib/Optimizer/Builder/FIRBuilder.cpp
index 7f03f3f050d5fd..b48b4fccb607b3 100644
--- a/flang/lib/Optimizer/Builder/FIRBuilder.cpp
+++ b/flang/lib/Optimizer/Builder/FIRBuilder.cpp
@@ -877,7 +877,9 @@ mlir::Value fir::FirOpBuilder::createBox(mlir::Location loc, mlir::Type boxType,
tdesc);
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void fir::FirOpBuilder::dumpFunc() { getFunction().dump(); }
+#endif
static mlir::Value
genNullPointerComparison(fir::FirOpBuilder &builder, mlir::Location loc,
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index 43c23ba28fa9e7..0ae7ca17bcef9d 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -3499,7 +3499,8 @@ IntrinsicLibrary::genChdir(std::optional<mlir::Type> resultType,
// Subroutine form, store status and return none.
if (!isStaticallyAbsent(args[1])) {
mlir::Value statusAddr = fir::getBase(args[1]);
- statusAddr.dump();
+ statusAddr.print(llvm::errs(), mlir::OpPrintingFlags().useLocalScope());
+ llvm::errs() << "\n";
mlir::Value statusIsPresentAtRuntime =
builder.genIsNotNullAddr(loc, statusAddr);
builder.genIfThen(loc, statusIsPresentAtRuntime)
diff --git a/mlir/examples/toy/Ch2/toyc.cpp b/mlir/examples/toy/Ch2/toyc.cpp
index a60738da9d4aeb..89eb8ef803ff53 100644
--- a/mlir/examples/toy/Ch2/toyc.cpp
+++ b/mlir/examples/toy/Ch2/toyc.cpp
@@ -87,7 +87,8 @@ static int dumpMLIR() {
if (!module)
return 1;
- module->dump();
+ module->print(llvm::errs(), mlir::OpPrintingFlags().useLocalScope());
+ llvm::errs() << "\n";
return 0;
}
@@ -109,7 +110,8 @@ static int dumpMLIR() {
return 3;
}
- module->dump();
+ module->print(llvm::errs(), mlir::OpPrintingFlags().useLocalScope());
+ llvm::errs() << "\n";
return 0;
}
diff --git a/mlir/examples/toy/Ch3/toyc.cpp b/mlir/examples/toy/Ch3/toyc.cpp
index 3094935567d94c..84d55dd89e9675 100644
--- a/mlir/examples/toy/Ch3/toyc.cpp
+++ b/mlir/examples/toy/Ch3/toyc.cpp
@@ -131,7 +131,8 @@ static int dumpMLIR() {
return 4;
}
- module->dump();
+ module->print(llvm::errs(), mlir::OpPrintingFlags().useLocalScope());
+ llvm::errs() << "\n";
return 0;
}
diff --git a/mlir/examples/toy/Ch4/toyc.cpp b/mlir/examples/toy/Ch4/toyc.cpp
index 36816f0327deeb..265de64c70feef 100644
--- a/mlir/examples/toy/Ch4/toyc.cpp
+++ b/mlir/examples/toy/Ch4/toyc.cpp
@@ -140,7 +140,8 @@ static int dumpMLIR() {
return 4;
}
- module->dump();
+ module->print(llvm::errs(), mlir::OpPrintingFlags().useLocalScope());
+ llvm::errs() << "\n";
return 0;
}
diff --git a/mlir/examples/toy/Ch5/toyc.cpp b/mlir/examples/toy/Ch5/toyc.cpp
index d62a1c0042f625..d119bd67fec4dc 100644
--- a/mlir/examples/toy/Ch5/toyc.cpp
+++ b/mlir/examples/toy/Ch5/toyc.cpp
@@ -168,7 +168,8 @@ static int dumpMLIR() {
if (mlir::failed(pm.run(*module)))
return 4;
- module->dump();
+ module->print(llvm::errs(), mlir::OpPrintingFlags().useLocalScope());
+ llvm::errs() << "\n";
return 0;
}
diff --git a/mlir/examples/toy/Ch6/toyc.cpp b/mlir/examples/toy/Ch6/toyc.cpp
index cfc10a7259180f..af7405920a55de 100644
--- a/mlir/examples/toy/Ch6/toyc.cpp
+++ b/mlir/examples/toy/Ch6/toyc.cpp
@@ -315,7 +315,8 @@ int main(int argc, char **argv) {
// If we aren't exporting to non-mlir, then we are done.
bool isOutputingMLIR = emitAction <= Action::DumpMLIRLLVM;
if (isOutputingMLIR) {
- module->dump();
+ module->print(llvm::errs(), mlir::OpPrintingFlags().useLocalScope());
+ llvm::errs() << "\n";
return 0;
}
diff --git a/mlir/examples/toy/Ch7/toyc.cpp b/mlir/examples/toy/Ch7/toyc.cpp
index ffd94bc8f71778..f153a784a62864 100644
--- a/mlir/examples/toy/Ch7/toyc.cpp
+++ b/mlir/examples/toy/Ch7/toyc.cpp
@@ -316,7 +316,8 @@ int main(int argc, char **argv) {
// If we aren't exporting to non-mlir, then we are done.
bool isOutputingMLIR = emitAction <= Action::DumpMLIRLLVM;
if (isOutputingMLIR) {
- module->dump();
+ module->print(llvm::errs(), mlir::OpPrintingFlags().useLocalScope());
+ llvm::errs() << "\n";
return 0;
}
diff --git a/mlir/examples/transform-opt/mlir-transform-opt.cpp b/mlir/examples/transform-opt/mlir-transform-opt.cpp
index 4b12e7610d0a8f..bdd4ce0185cfef 100644
--- a/mlir/examples/transform-opt/mlir-transform-opt.cpp
+++ b/mlir/examples/transform-opt/mlir-transform-opt.cpp
@@ -308,8 +308,10 @@ static llvm::LogicalResult processPayloadBuffer(
}
// If requested, dump the combined transform module.
- if (clOptions->dumpLibraryModule)
- transformRoot->dump();
+ if (clOptions->dumpLibraryModule) {
+ transformRoot->print(os, mlir::OpPrintingFlags().useLocalScope());
+ os << "\n";
+ }
// Find the entry point symbol. Even if it had originally been in the payload
// module, it was cloned into the transform module so only look there.
diff --git a/mlir/include/mlir/Analysis/CallGraph.h b/mlir/include/mlir/Analysis/CallGraph.h
index fc342255c5ca1f..ad2f4d1528725f 100644
--- a/mlir/include/mlir/Analysis/CallGraph.h
+++ b/mlir/include/mlir/Analysis/CallGraph.h
@@ -208,7 +208,9 @@ class CallGraph {
iterator end() const { return nodes.end(); }
/// Dump the graph in a human readable format.
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
+#endif
void print(raw_ostream &os) const;
private:
diff --git a/mlir/include/mlir/Analysis/Liveness.h b/mlir/include/mlir/Analysis/Liveness.h
index 23d9543a1af43b..aa51aa68373508 100644
--- a/mlir/include/mlir/Analysis/Liveness.h
+++ b/mlir/include/mlir/Analysis/Liveness.h
@@ -78,7 +78,9 @@ class Liveness {
bool isDeadAfter(Value value, Operation *operation) const;
/// Dumps the liveness information in a human readable format.
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
+#endif
/// Dumps the liveness information to the given stream.
void print(raw_ostream &os) const;
diff --git a/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h b/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h
index ce6e9df1540774..f79152f46ca73a 100644
--- a/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h
+++ b/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h
@@ -849,7 +849,9 @@ class IntegerRelation {
bool isFullDim();
void print(raw_ostream &os) const;
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
+#endif
protected:
/// Checks all rows of equality/inequality constraints for trivial
diff --git a/mlir/include/mlir/Analysis/Presburger/Matrix.h b/mlir/include/mlir/Analysis/Presburger/Matrix.h
index 3c034043c419d3..69177e7ef84d34 100644
--- a/mlir/include/mlir/Analysis/Presburger/Matrix.h
+++ b/mlir/include/mlir/Analysis/Presburger/Matrix.h
@@ -210,7 +210,9 @@ class Matrix {
/// Print the matrix.
void print(raw_ostream &os) const;
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
+#endif
/// Return whether the Matrix is in a consistent state with all its
/// invariants satisfied.
diff --git a/mlir/include/mlir/Analysis/Presburger/PWMAFunction.h b/mlir/include/mlir/Analysis/Presburger/PWMAFunction.h
index e7a3e271673bfa..99690dced87c1d 100644
--- a/mlir/include/mlir/Analysis/Presburger/PWMAFunction.h
+++ b/mlir/include/mlir/Analysis/Presburger/PWMAFunction.h
@@ -110,7 +110,9 @@ class MultiAffineFunction {
IntegerRelation getAsRelation() const;
void print(raw_ostream &os) const;
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
+#endif
private:
/// Assert that the MAF is consistent.
@@ -221,7 +223,9 @@ class PWMAFunction {
PWMAFunction unionLexMax(const PWMAFunction &func);
void print(raw_ostream &os) const;
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
+#endif
private:
/// Return a function defined on the union of the domains of `this` and
diff --git a/mlir/include/mlir/Analysis/Presburger/PresburgerRelation.h b/mlir/include/mlir/Analysis/Presburger/PresburgerRelation.h
index 778f99d9414ff5..8c014f0007eca4 100644
--- a/mlir/include/mlir/Analysis/Presburger/PresburgerRelation.h
+++ b/mlir/include/mlir/Analysis/Presburger/PresburgerRelation.h
@@ -223,7 +223,9 @@ class PresburgerRelation {
/// Print the set's internal state.
void print(raw_ostream &os) const;
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
+#endif
protected:
/// Construct an empty PresburgerRelation with the specified number of
diff --git a/mlir/include/mlir/Analysis/Presburger/PresburgerSpace.h b/mlir/include/mlir/Analysis/Presburger/PresburgerSpace.h
index ede6f4279fe90e..8e43ec73945826 100644
--- a/mlir/include/mlir/Analysis/Presburger/PresburgerSpace.h
+++ b/mlir/include/mlir/Analysis/Presburger/PresburgerSpace.h
@@ -102,7 +102,9 @@ class Identifier {
bool operator!=(const Identifier &other) const { return !isEqual(other); }
void print(llvm::raw_ostream &os) const;
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
+#endif
private:
/// The value of the identifier.
@@ -311,7 +313,9 @@ class PresburgerSpace {
void mergeAndAlignSymbols(PresburgerSpace &other);
void print(llvm::raw_ostream &os) const;
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
+#endif
protected:
PresburgerSpace(unsigned numDomain, unsigned numRange, unsigned numSymbols,
diff --git a/mlir/include/mlir/Analysis/Presburger/Simplex.h b/mlir/include/mlir/Analysis/Presburger/Simplex.h
index 163ae249752530..e7b0fb3dbd6f4e 100644
--- a/mlir/include/mlir/Analysis/Presburger/Simplex.h
+++ b/mlir/include/mlir/Analysis/Presburger/Simplex.h
@@ -205,7 +205,9 @@ class SimplexBase {
/// Print the tableau's internal state.
void print(raw_ostream &os) const;
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
+#endif
protected:
/// Construct a SimplexBase with the specified number of variables and fixed
diff --git a/mlir/include/mlir/Analysis/Presburger/Utils.h b/mlir/include/mlir/Analysis/Presburger/Utils.h
index a4083a9eb20550..1e23fdcbe34153 100644
--- a/mlir/include/mlir/Analysis/Presburger/Utils.h
+++ b/mlir/include/mlir/Analysis/Presburger/Utils.h
@@ -182,7 +182,9 @@ class DivisionRepr {
removeDuplicateDivs(llvm::function_ref<bool(unsigned i, unsigned j)> merge);
void print(raw_ostream &os) const;
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
+#endif
private:
/// Each row of the Matrix represents a single division dividend. The
diff --git a/mlir/include/mlir/Debug/ExecutionContext.h b/mlir/include/mlir/Debug/ExecutionContext.h
index e2a5f3d0f32697..1d7d2fd20a8655 100644
--- a/mlir/include/mlir/Debug/ExecutionContext.h
+++ b/mlir/include/mlir/Debug/ExecutionContext.h
@@ -29,7 +29,9 @@ struct ActionActiveStack {
const Action &getAction() const { return action; }
int getDepth() const { return depth; }
void print(raw_ostream &os, bool withContext) const;
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
+#endif
Breakpoint *getBreakpoint() const { return breakpoint; }
void setBreakpoint(Breakpoint *breakpoint) { this->breakpoint = breakpoint; }
diff --git a/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h b/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h
index 5365e381856f71..4555bf4931e1c4 100644
--- a/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h
+++ b/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h
@@ -264,7 +264,9 @@ struct MemRefDependenceGraph {
void print(raw_ostream &os) const;
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const { print(llvm::errs()); }
+#endif
/// The block for which this graph is created to perform fusion.
Block █
@@ -372,7 +374,9 @@ struct ComputationSliceState {
/// If the validity cannot be determined, returns std::nullopt.
std::optional<bool> isSliceValid() const;
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
+#endif
private:
/// Fast check to determine if the computation slice is maximal. Returns true
diff --git a/mlir/include/mlir/IR/AffineExpr.h b/mlir/include/mlir/IR/AffineExpr.h
index 3f26afe5e0856f..effa8588a8a277 100644
--- a/mlir/include/mlir/IR/AffineExpr.h
+++ b/mlir/include/mlir/IR/AffineExpr.h
@@ -87,7 +87,9 @@ class AffineExpr {
AffineExprKind getKind() const;
void print(raw_ostream &os) const;
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
+#endif
/// Returns true if this expression is made out of only symbols and
/// constants, i.e., it does not involve dimensional identifiers.
diff --git a/mlir/include/mlir/IR/AffineMap.h b/mlir/include/mlir/IR/AffineMap.h
index 98792775c23cfa..ed2041657a3dc1 100644
--- a/mlir/include/mlir/IR/AffineMap.h
+++ b/mlir/include/mlir/IR/AffineMap.h
@@ -198,7 +198,9 @@ class AffineMap {
// Prints affine map to 'os'.
void print(raw_ostream &os) const;
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
+#endif
unsigned getNumDims() const;
unsigned getNumSymbols() const;
diff --git a/mlir/include/mlir/IR/Attributes.h b/mlir/include/mlir/IR/Attributes.h
index 389ba95d9be971..54b08162b70b5c 100644
--- a/mlir/include/mlir/IR/Attributes.h
+++ b/mlir/include/mlir/IR/Attributes.h
@@ -63,7 +63,9 @@ class Attribute {
/// without a trailing colon type if it has one.
void print(raw_ostream &os, bool elideType = false) const;
void print(raw_ostream &os, AsmState &state, bool elideType = false) const;
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
+#endif
/// Print the attribute without dialect wrapping.
void printStripped(raw_ostream &os) const;
diff --git a/mlir/include/mlir/IR/Block.h b/mlir/include/mlir/IR/Block.h
index 7611f5320c82b1..22a105c40f5fe8 100644
--- a/mlir/include/mlir/IR/Block.h
+++ b/mlir/include/mlir/IR/Block.h
@@ -406,7 +406,9 @@ class alignas(8) Block : public IRObjectWithUseList<BlockOperand>,
void print(raw_ostream &os);
void print(raw_ostream &os, AsmState &state);
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump();
+#endif
/// Print out the name of the block without printing its body.
/// NOTE: The printType argument is ignored. We keep it for compatibility
diff --git a/mlir/include/mlir/IR/IntegerSet.h b/mlir/include/mlir/IR/IntegerSet.h
index 088a4ca42da242..2992539d5ad3d9 100644
--- a/mlir/include/mlir/IR/IntegerSet.h
+++ b/mlir/include/mlir/IR/IntegerSet.h
@@ -103,7 +103,9 @@ class IntegerSet {
void walkExprs(function_ref<void(AffineExpr)> callback) const;
void print(raw_ostream &os) const;
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
+#endif
friend ::llvm::hash_code hash_value(IntegerSet arg);
diff --git a/mlir/include/mlir/IR/Location.h b/mlir/include/mlir/IR/Location.h
index a8f458343b701d..610d0f20426bd5 100644
--- a/mlir/include/mlir/IR/Location.h
+++ b/mlir/include/mlir/IR/Location.h
@@ -95,7 +95,9 @@ class Location {
/// Print the location.
void print(raw_ostream &os) const { impl.print(os); }
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const { impl.dump(); }
+#endif
friend ::llvm::hash_code hash_value(Location arg);
diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h
index 15bbe5730c3e27..194d43f9658f6f 100644
--- a/mlir/include/mlir/IR/OpDefinition.h
+++ b/mlir/include/mlir/IR/OpDefinition.h
@@ -123,7 +123,9 @@ class OpState {
}
/// Dump this operation.
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() { state->dump(); }
+#endif
/// The source location the operation was defined or derived from.
Location getLoc() { return state->getLoc(); }
diff --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h
index adddd8572f2a3c..14a2c6ac287995 100644
--- a/mlir/include/mlir/IR/Operation.h
+++ b/mlir/include/mlir/IR/Operation.h
@@ -345,7 +345,9 @@ class alignas(8) Operation final
void print(raw_ostream &os, const OpPrintingFlags &flags = {});
void print(raw_ostream &os, AsmState &state);
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump();
+#endif
// Dump pretty printed IR. This method is helpful for better readability if
// the Operation is not verified because it won't disable custom printers to
diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h
index 68be626d7a560b..d5b6b18cb015c9 100644
--- a/mlir/include/mlir/IR/OperationSupport.h
+++ b/mlir/include/mlir/IR/OperationSupport.h
@@ -541,7 +541,9 @@ class OperationName {
StringAttr getIdentifier() const { return getImpl()->getName(); }
void print(raw_ostream &os) const;
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
+#endif
/// Represent the operation name as an opaque pointer. (Used to support
/// PointerLikeTypeTraits).
diff --git a/mlir/include/mlir/IR/Types.h b/mlir/include/mlir/IR/Types.h
index 89c93cf0687bf3..717218180b2604 100644
--- a/mlir/include/mlir/IR/Types.h
+++ b/mlir/include/mlir/IR/Types.h
@@ -159,7 +159,9 @@ class Type {
/// Print the current type.
void print(raw_ostream &os) const;
void print(raw_ostream &os, AsmState &state) const;
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
+#endif
friend ::llvm::hash_code hash_value(Type arg);
diff --git a/mlir/include/mlir/IR/Value.h b/mlir/include/mlir/IR/Value.h
index d5cef1f0c44ba3..dccaf11c87eb87 100644
--- a/mlir/include/mlir/IR/Value.h
+++ b/mlir/include/mlir/IR/Value.h
@@ -223,7 +223,9 @@ class Value {
void print(raw_ostream &os) const;
void print(raw_ostream &os, const OpPrintingFlags &flags) const;
void print(raw_ostream &os, AsmState &state) const;
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
+#endif
/// Print this value as if it were an operand.
void printAsOperand(raw_ostream &os, AsmState &state) const;
diff --git a/mlir/include/mlir/Interfaces/InferTypeOpInterface.h b/mlir/include/mlir/Interfaces/InferTypeOpInterface.h
index 90ce18aad0cb03..80760340c345ff 100644
--- a/mlir/include/mlir/Interfaces/InferTypeOpInterface.h
+++ b/mlir/include/mlir/Interfaces/InferTypeOpInterface.h
@@ -92,7 +92,9 @@ class ShapeAdaptor {
explicit operator bool() const { return !val.isNull(); }
/// Dumps textual repesentation to stderr.
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
+#endif
private:
// Union storing either ShapedTypeComponents, ShapedType (stored as Type and
diff --git a/mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h b/mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h
index 593d4398a4f7ec..89239665922e9c 100644
--- a/mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h
+++ b/mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h
@@ -353,7 +353,9 @@ class ValueBoundsConstraintSet
/// Debugging only: Dump the constraint set and the column-to-value/dim
/// mapping to llvm::errs.
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
+#endif
protected:
/// Dimension identifier to indicate a value is index-typed. This is used for
diff --git a/mlir/include/mlir/Pass/PassManager.h b/mlir/include/mlir/Pass/PassManager.h
index a3ff667940a322..6acfa6a33affde 100644
--- a/mlir/include/mlir/Pass/PassManager.h
+++ b/mlir/include/mlir/Pass/PassManager.h
@@ -148,7 +148,9 @@ class OpPassManager {
void printAsTextualPipeline(raw_ostream &os, bool pretty = false) const;
/// Raw dump of the pass manager to llvm::errs().
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump();
+#endif
/// Merge the pass statistics of this class into 'other'.
void mergeStatisticsInto(OpPassManager &other);
diff --git a/mlir/lib/Analysis/CallGraph.cpp b/mlir/lib/Analysis/CallGraph.cpp
index 4098c657f63e2a..57e56cc5e1ecb3 100644
--- a/mlir/lib/Analysis/CallGraph.cpp
+++ b/mlir/lib/Analysis/CallGraph.cpp
@@ -176,7 +176,9 @@ void CallGraph::eraseNode(CallGraphNode *node) {
//===----------------------------------------------------------------------===//
/// Dump the graph in a human readable format.
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void CallGraph::dump() const { print(llvm::errs()); }
+#endif
void CallGraph::print(raw_ostream &os) const {
os << "// ---- CallGraph ----\n";
diff --git a/mlir/lib/Analysis/Liveness.cpp b/mlir/lib/Analysis/Liveness.cpp
index 3fcc0b5a6ffef2..5bd7cc00c9004c 100644
--- a/mlir/lib/Analysis/Liveness.cpp
+++ b/mlir/lib/Analysis/Liveness.cpp
@@ -254,7 +254,9 @@ bool Liveness::isDeadAfter(Value value, Operation *operation) const {
}
/// Dumps the liveness information in a human readable format.
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void Liveness::dump() const { print(llvm::errs()); }
+#endif
/// Dumps the liveness information to the given stream.
void Liveness::print(raw_ostream &os) const {
diff --git a/mlir/lib/Analysis/Presburger/IntegerRelation.cpp b/mlir/lib/Analysis/Presburger/IntegerRelation.cpp
index 94a15dc3f8663d..e76e2ead02e64c 100644
--- a/mlir/lib/Analysis/Presburger/IntegerRelation.cpp
+++ b/mlir/lib/Analysis/Presburger/IntegerRelation.cpp
@@ -2744,7 +2744,9 @@ void IntegerRelation::print(raw_ostream &os) const {
os << '\n';
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void IntegerRelation::dump() const { print(llvm::errs()); }
+#endif
unsigned IntegerPolyhedron::insertVar(VarKind kind, unsigned pos,
unsigned num) {
diff --git a/mlir/lib/Analysis/Presburger/Matrix.cpp b/mlir/lib/Analysis/Presburger/Matrix.cpp
index 7c55caa767c451..263ada0a05ebae 100644
--- a/mlir/lib/Analysis/Presburger/Matrix.cpp
+++ b/mlir/lib/Analysis/Presburger/Matrix.cpp
@@ -433,10 +433,12 @@ Matrix<T>::splitByBitset(ArrayRef<int> indicator) {
return {rowsForOne, rowsForZero};
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
template <typename T>
void Matrix<T>::dump() const {
print(llvm::errs());
}
+#endif
template <typename T>
bool Matrix<T>::hasConsistentState() const {
diff --git a/mlir/lib/Analysis/Presburger/PWMAFunction.cpp b/mlir/lib/Analysis/Presburger/PWMAFunction.cpp
index 2c55e406463458..a472bf14e4ca11 100644
--- a/mlir/lib/Analysis/Presburger/PWMAFunction.cpp
+++ b/mlir/lib/Analysis/Presburger/PWMAFunction.cpp
@@ -65,7 +65,9 @@ void MultiAffineFunction::print(raw_ostream &os) const {
output.print(os);
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void MultiAffineFunction::dump() const { print(llvm::errs()); }
+#endif
SmallVector<DynamicAPInt, 8>
MultiAffineFunction::valueAt(ArrayRef<DynamicAPInt> point) const {
@@ -311,7 +313,9 @@ void PWMAFunction::print(raw_ostream &os) const {
}
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void PWMAFunction::dump() const { print(llvm::errs()); }
+#endif
PWMAFunction PWMAFunction::unionFunction(
const PWMAFunction &func,
diff --git a/mlir/lib/Analysis/Presburger/PresburgerRelation.cpp b/mlir/lib/Analysis/Presburger/PresburgerRelation.cpp
index ea7dfdcd93c0d4..5dceeb35e8345a 100644
--- a/mlir/lib/Analysis/Presburger/PresburgerRelation.cpp
+++ b/mlir/lib/Analysis/Presburger/PresburgerRelation.cpp
@@ -1056,7 +1056,9 @@ void PresburgerRelation::print(raw_ostream &os) const {
}
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void PresburgerRelation::dump() const { print(llvm::errs()); }
+#endif
PresburgerSet PresburgerSet::getUniverse(const PresburgerSpace &space) {
PresburgerSet result(space);
diff --git a/mlir/lib/Analysis/Presburger/PresburgerSpace.cpp b/mlir/lib/Analysis/Presburger/PresburgerSpace.cpp
index 532c464925b1a1..208ee418b26c87 100644
--- a/mlir/lib/Analysis/Presburger/PresburgerSpace.cpp
+++ b/mlir/lib/Analysis/Presburger/PresburgerSpace.cpp
@@ -30,10 +30,12 @@ void Identifier::print(llvm::raw_ostream &os) const {
os << "Id<" << value << ">";
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void Identifier::dump() const {
print(llvm::errs());
llvm::errs() << "\n";
}
+#endif
PresburgerSpace PresburgerSpace::getDomainSpace() const {
PresburgerSpace newSpace = *this;
@@ -354,7 +356,9 @@ void PresburgerSpace::print(llvm::raw_ostream &os) const {
}
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void PresburgerSpace::dump() const {
print(llvm::errs());
llvm::errs() << "\n";
}
+#endif
diff --git a/mlir/lib/Analysis/Presburger/Simplex.cpp b/mlir/lib/Analysis/Presburger/Simplex.cpp
index f2e6f83e99e57f..aab1534ad30e8c 100644
--- a/mlir/lib/Analysis/Presburger/Simplex.cpp
+++ b/mlir/lib/Analysis/Presburger/Simplex.cpp
@@ -2167,7 +2167,9 @@ void SimplexBase::print(raw_ostream &os) const {
os << '\n';
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void SimplexBase::dump() const { print(llvm::errs()); }
+#endif
bool Simplex::isRationalSubsetOf(const IntegerRelation &rel) {
if (isEmpty())
diff --git a/mlir/lib/Analysis/Presburger/Utils.cpp b/mlir/lib/Analysis/Presburger/Utils.cpp
index a06a854fd14260..bbe86ddd96f6e1 100644
--- a/mlir/lib/Analysis/Presburger/Utils.cpp
+++ b/mlir/lib/Analysis/Presburger/Utils.cpp
@@ -516,7 +516,9 @@ void DivisionRepr::print(raw_ostream &os) const {
os << "\n";
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void DivisionRepr::dump() const { print(llvm::errs()); }
+#endif
SmallVector<DynamicAPInt, 8>
presburger::getDynamicAPIntVec(ArrayRef<int64_t> range) {
diff --git a/mlir/lib/CAPI/IR/AffineExpr.cpp b/mlir/lib/CAPI/IR/AffineExpr.cpp
index 5a0a03b11ae457..bbe59b4ec51941 100644
--- a/mlir/lib/CAPI/IR/AffineExpr.cpp
+++ b/mlir/lib/CAPI/IR/AffineExpr.cpp
@@ -32,7 +32,8 @@ void mlirAffineExprPrint(MlirAffineExpr affineExpr, MlirStringCallback callback,
}
void mlirAffineExprDump(MlirAffineExpr affineExpr) {
- unwrap(affineExpr).dump();
+ unwrap(affineExpr).print(llvm::errs());
+ llvm::errs() << "\n";
}
bool mlirAffineExprIsSymbolicOrConstant(MlirAffineExpr affineExpr) {
diff --git a/mlir/lib/CAPI/IR/AffineMap.cpp b/mlir/lib/CAPI/IR/AffineMap.cpp
index 1889765ef86421..b38b47baf7ed55 100644
--- a/mlir/lib/CAPI/IR/AffineMap.cpp
+++ b/mlir/lib/CAPI/IR/AffineMap.cpp
@@ -32,7 +32,10 @@ void mlirAffineMapPrint(MlirAffineMap affineMap, MlirStringCallback callback,
unwrap(affineMap).print(stream);
}
-void mlirAffineMapDump(MlirAffineMap affineMap) { unwrap(affineMap).dump(); }
+void mlirAffineMapDump(MlirAffineMap affineMap) {
+ unwrap(affineMap).print(llvm::errs());
+ llvm::errs() << "\n";
+}
MlirAffineMap mlirAffineMapEmptyGet(MlirContext ctx) {
return wrap(AffineMap::get(unwrap(ctx)));
diff --git a/mlir/lib/CAPI/IR/IR.cpp b/mlir/lib/CAPI/IR/IR.cpp
index e01e49559eb17a..95e7749a2d8c1d 100644
--- a/mlir/lib/CAPI/IR/IR.cpp
+++ b/mlir/lib/CAPI/IR/IR.cpp
@@ -915,7 +915,10 @@ MlirLogicalResult mlirOperationWriteBytecodeWithConfig(
return wrap(writeBytecodeToFile(unwrap(op), stream, *unwrap(config)));
}
-void mlirOperationDump(MlirOperation op) { return unwrap(op)->dump(); }
+void mlirOperationDump(MlirOperation op) {
+ unwrap(op)->print(llvm::errs(), OpPrintingFlags().useLocalScope());
+ llvm::errs() << "\n";
+}
bool mlirOperationVerify(MlirOperation op) {
return succeeded(verify(unwrap(op)));
@@ -1219,7 +1222,10 @@ void mlirValueSetType(MlirValue value, MlirType type) {
unwrap(value).setType(unwrap(type));
}
-void mlirValueDump(MlirValue value) { unwrap(value).dump(); }
+void mlirValueDump(MlirValue value) {
+ unwrap(value).print(llvm::errs(), OpPrintingFlags().useLocalScope());
+ llvm::errs() << "\n";
+}
void mlirValuePrint(MlirValue value, MlirStringCallback callback,
void *userData) {
@@ -1340,7 +1346,10 @@ void mlirTypePrint(MlirType type, MlirStringCallback callback, void *userData) {
unwrap(type).print(stream);
}
-void mlirTypeDump(MlirType type) { unwrap(type).dump(); }
+void mlirTypeDump(MlirType type) {
+ unwrap(type).print(llvm::errs());
+ llvm::errs() << "\n";
+}
//===----------------------------------------------------------------------===//
// Attribute API.
@@ -1379,7 +1388,10 @@ void mlirAttributePrint(MlirAttribute attr, MlirStringCallback callback,
unwrap(attr).print(stream);
}
-void mlirAttributeDump(MlirAttribute attr) { unwrap(attr).dump(); }
+void mlirAttributeDump(MlirAttribute attr) {
+ unwrap(attr).print(llvm::errs());
+ llvm::errs() << "\n";
+}
MlirNamedAttribute mlirNamedAttributeGet(MlirIdentifier name,
MlirAttribute attr) {
diff --git a/mlir/lib/CAPI/IR/IntegerSet.cpp b/mlir/lib/CAPI/IR/IntegerSet.cpp
index 43d48e415d27a2..da4dce68d5ede8 100644
--- a/mlir/lib/CAPI/IR/IntegerSet.cpp
+++ b/mlir/lib/CAPI/IR/IntegerSet.cpp
@@ -30,7 +30,10 @@ void mlirIntegerSetPrint(MlirIntegerSet set, MlirStringCallback callback,
unwrap(set).print(stream);
}
-void mlirIntegerSetDump(MlirIntegerSet set) { unwrap(set).dump(); }
+void mlirIntegerSetDump(MlirIntegerSet set) {
+ unwrap(set).print(llvm::errs());
+ llvm::errs() << "\n";
+}
MlirIntegerSet mlirIntegerSetEmptyGet(MlirContext context, intptr_t numDims,
intptr_t numSymbols) {
diff --git a/mlir/lib/Conversion/SPIRVCommon/Pattern.h b/mlir/lib/Conversion/SPIRVCommon/Pattern.h
index d947d483f2dd55..159ef521c7b938 100644
--- a/mlir/lib/Conversion/SPIRVCommon/Pattern.h
+++ b/mlir/lib/Conversion/SPIRVCommon/Pattern.h
@@ -38,7 +38,8 @@ struct ElementwiseOpPattern : public OpConversionPattern<Op> {
if (SPIRVOp::template hasTrait<OpTrait::spirv::UnsignedOp>() &&
!getElementTypeOrSelf(op.getType()).isIndex() &&
dstType != op.getType()) {
- op.dump();
+ op.print(llvm::errs(), OpPrintingFlags().useLocalScope());
+ llvm::errs() << "\n";
return op.emitError("bitwidth emulation is not implemented yet on "
"unsigned op pattern version");
}
diff --git a/mlir/lib/Debug/ExecutionContext.cpp b/mlir/lib/Debug/ExecutionContext.cpp
index 1fd38349b0f5d9..74aa4cdd0ba9a2 100644
--- a/mlir/lib/Debug/ExecutionContext.cpp
+++ b/mlir/lib/Debug/ExecutionContext.cpp
@@ -42,10 +42,12 @@ void ActionActiveStack::print(raw_ostream &os, bool withContext) const {
}
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void ActionActiveStack::dump() const {
print(llvm::errs(), /*withContext=*/true);
llvm::errs() << "\n";
}
+#endif
//===----------------------------------------------------------------------===//
// ExecutionContext
diff --git a/mlir/lib/Dialect/Affine/Analysis/Utils.cpp b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp
index 0e036dfedbf52e..4bca8ff7afd504 100644
--- a/mlir/lib/Dialect/Affine/Analysis/Utils.cpp
+++ b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp
@@ -949,6 +949,7 @@ void ComputationSliceState::clearBounds() {
ubOperands.clear();
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void ComputationSliceState::dump() const {
llvm::errs() << "\tIVs:\n";
for (Value iv : ivs)
@@ -970,6 +971,7 @@ void ComputationSliceState::dump() const {
llvm::errs() << "\t\t\t" << ubOp << "\n";
}
}
+#endif
/// Fast check to determine if the computation slice is maximal. Returns true if
/// each slice dimension maps to an existing dst dimension and both the src
diff --git a/mlir/lib/Dialect/SparseTensor/IR/Detail/Var.cpp b/mlir/lib/Dialect/SparseTensor/IR/Detail/Var.cpp
index 069191c21b0919..bac1c3ccb82192 100644
--- a/mlir/lib/Dialect/SparseTensor/IR/Detail/Var.cpp
+++ b/mlir/lib/Dialect/SparseTensor/IR/Detail/Var.cpp
@@ -38,10 +38,12 @@ void Var::print(llvm::raw_ostream &os) const {
os << toChar(getKind()) << getNum();
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void Var::dump() const {
print(llvm::errs());
llvm::errs() << "\n";
}
+#endif
//===----------------------------------------------------------------------===//
// `Ranks` implementation.
diff --git a/mlir/lib/Dialect/SparseTensor/IR/Detail/Var.h b/mlir/lib/Dialect/SparseTensor/IR/Detail/Var.h
index 36e4785d5efd95..ef9794b893a063 100644
--- a/mlir/lib/Dialect/SparseTensor/IR/Detail/Var.h
+++ b/mlir/lib/Dialect/SparseTensor/IR/Detail/Var.h
@@ -134,7 +134,9 @@ class Var {
std::string str() const;
void print(llvm::raw_ostream &os) const;
void print(AsmPrinter &printer) const;
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
+#endif
};
static_assert(IsZeroCostAbstraction<Var>);
diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index 93fdf69cf286d5..a2c4c81a3ecad8 100644
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -59,7 +59,9 @@ using namespace mlir::detail;
void OperationName::print(raw_ostream &os) const { os << getStringRef(); }
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void OperationName::dump() const { print(llvm::errs()); }
+#endif
//===--------------------------------------------------------------------===//
// AsmParser
@@ -4084,10 +4086,12 @@ void Attribute::print(raw_ostream &os, AsmState &state, bool elideType) const {
: AttrTypeElision::Never);
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void Attribute::dump() const {
print(llvm::errs());
llvm::errs() << "\n";
}
+#endif
void Attribute::printStripped(raw_ostream &os, AsmState &state) const {
if (!*this) {
@@ -4133,6 +4137,7 @@ void Type::print(raw_ostream &os, AsmState &state) const {
AsmPrinter::Impl(os, state.getImpl()).printType(*this);
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void Type::dump() const {
print(llvm::errs());
llvm::errs() << "\n";
@@ -4147,6 +4152,7 @@ void IntegerSet::dump() const {
print(llvm::errs());
llvm::errs() << "\n";
}
+#endif
void AffineExpr::print(raw_ostream &os) const {
if (!expr) {
@@ -4157,10 +4163,12 @@ void AffineExpr::print(raw_ostream &os) const {
AsmPrinter::Impl(os, state.getImpl()).printAffineExpr(*this);
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void AffineExpr::dump() const {
print(llvm::errs());
llvm::errs() << "\n";
}
+#endif
void AffineMap::print(raw_ostream &os) const {
if (!map) {
@@ -4210,10 +4218,12 @@ raw_ostream &mlir::operator<<(raw_ostream &os, Value value) {
return os;
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void Value::dump() const {
print(llvm::errs(), OpPrintingFlags().useLocalScope());
llvm::errs() << "\n";
}
+#endif
void Value::printAsOperand(raw_ostream &os, AsmState &state) const {
// TODO: This doesn't necessarily capture all potential cases.
@@ -4278,10 +4288,12 @@ void Operation::print(raw_ostream &os, AsmState &state) {
}
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void Operation::dump() {
print(llvm::errs(), OpPrintingFlags().useLocalScope());
llvm::errs() << "\n";
}
+#endif
void Operation::dumpPretty() {
print(llvm::errs(), OpPrintingFlags().useLocalScope().assumeVerified());
@@ -4305,7 +4317,9 @@ void Block::print(raw_ostream &os, AsmState &state) {
OperationPrinter(os, state.getImpl()).print(this);
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void Block::dump() { print(llvm::errs()); }
+#endif
/// Print out the name of the block without printing its body.
void Block::printAsOperand(raw_ostream &os, bool printType) {
diff --git a/mlir/lib/Interfaces/InferTypeOpInterface.cpp b/mlir/lib/Interfaces/InferTypeOpInterface.cpp
index c31e0ae7470e2e..4aade476714ea9 100644
--- a/mlir/lib/Interfaces/InferTypeOpInterface.cpp
+++ b/mlir/lib/Interfaces/InferTypeOpInterface.cpp
@@ -180,6 +180,7 @@ int64_t ShapeAdaptor::getNumElements() const {
return num;
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void ShapeAdaptor::dump() const {
if (!hasRank()) {
llvm::errs() << "<<unranked>>\n";
@@ -196,6 +197,7 @@ void ShapeAdaptor::dump() const {
llvm::errs() << "rank = " << getRank()
<< " dims = " << llvm::interleaved_array(mapped, "x") << "\n";
}
+#endif
ShapeAdaptor ValueShapeRange::getValueAsShape(int index) {
Value val = operator[](index);
diff --git a/mlir/lib/Interfaces/ValueBoundsOpInterface.cpp b/mlir/lib/Interfaces/ValueBoundsOpInterface.cpp
index d998104e99f4a7..3c52be42b912da 100644
--- a/mlir/lib/Interfaces/ValueBoundsOpInterface.cpp
+++ b/mlir/lib/Interfaces/ValueBoundsOpInterface.cpp
@@ -984,6 +984,7 @@ FailureOr<bool> ValueBoundsConstraintSet::areEquivalentSlices(
return true;
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void ValueBoundsConstraintSet::dump() const {
llvm::errs() << "==========\nColumns:\n";
llvm::errs() << "(column\tdim\tvalue)\n";
@@ -1012,6 +1013,7 @@ void ValueBoundsConstraintSet::dump() const {
cstr.dump();
llvm::errs() << "==========\n";
}
+#endif
ValueBoundsConstraintSet::BoundBuilder &
ValueBoundsConstraintSet::BoundBuilder::operator[](int64_t dim) {
diff --git a/mlir/lib/Pass/Pass.cpp b/mlir/lib/Pass/Pass.cpp
index 656b8044587737..303562a2af6ee6 100644
--- a/mlir/lib/Pass/Pass.cpp
+++ b/mlir/lib/Pass/Pass.cpp
@@ -460,11 +460,13 @@ void OpPassManager::printAsTextualPipeline(raw_ostream &os, bool pretty) const {
pretty);
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void OpPassManager::dump() {
llvm::errs() << "Pass Manager with " << impl->passes.size() << " passes:\n";
printAsTextualPipeline(llvm::errs(), /*pretty=*/true);
llvm::errs() << "\n";
}
+#endif
static void registerDialectsForPipeline(const OpPassManager &pm,
DialectRegistry &dialects) {
diff --git a/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp b/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
index 490e0c20f86f6c..eda45fc7eaf732 100644
--- a/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
+++ b/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
@@ -377,9 +377,9 @@ MlirOptMainConfig &MlirOptMainConfig::setPassPipelineParser(
if (failed(passPipeline.addToPipeline(pm, errorHandler)))
return failure();
if (this->shouldDumpPassPipeline()) {
-
- pm.dump();
- llvm::errs() << "\n";
+ llvm::errs() << "Pass Manager with " << pm.size() << " passes:\n";
+ pm.printAsTextualPipeline(llvm::errs(), /*pretty=*/true);
+ llvm::errs() << "\n\n";
}
return success();
};
diff --git a/mlir/lib/Transforms/PrintIR.cpp b/mlir/lib/Transforms/PrintIR.cpp
index 0d6c1112902c21..1f2ba8cc59d79d 100644
--- a/mlir/lib/Transforms/PrintIR.cpp
+++ b/mlir/lib/Transforms/PrintIR.cpp
@@ -26,7 +26,8 @@ struct PrintIRPass : public impl::PrintIRPassBase<PrintIRPass> {
if (!this->label.empty())
llvm::dbgs() << " " << this->label;
llvm::dbgs() << " //----- //\n";
- getOperation()->dump();
+ getOperation()->print(llvm::dbgs(), OpPrintingFlags().useLocalScope());
+ llvm::dbgs() << "\n";
markAllAnalysesPreserved();
}
};
diff --git a/mlir/unittests/Analysis/Presburger/LinearTransformTest.cpp b/mlir/unittests/Analysis/Presburger/LinearTransformTest.cpp
index 388ac1174dcdc9..b23e362fdbaba7 100644
--- a/mlir/unittests/Analysis/Presburger/LinearTransformTest.cpp
+++ b/mlir/unittests/Analysis/Presburger/LinearTransformTest.cpp
@@ -30,7 +30,7 @@ void testColumnEchelonForm(const IntMatrix &m, unsigned expectedRank) {
EXPECT_EQ(rowVec[col], 0);
if (rowVec[col] != 0) {
llvm::errs() << "Failed at input matrix:\n";
- m.dump();
+ m.print(llvm::errs());
}
}
if (rowVec[lastAllowedNonZeroCol] != 0)
>From 37327a928f0d5457c200d74e8337ffa9171f82be Mon Sep 17 00:00:00 2001
From: "Golubev, Andrey" <andrey.golubev at intel.com>
Date: Mon, 19 Oct 2026 15:10:53 +0000
Subject: [PATCH 3/3] Drop explicit mlir::OpPrintingFlags in new print()
commands
---
mlir/examples/toy/Ch2/toyc.cpp | 4 ++--
mlir/examples/toy/Ch3/toyc.cpp | 2 +-
mlir/examples/toy/Ch4/toyc.cpp | 2 +-
mlir/examples/toy/Ch5/toyc.cpp | 2 +-
mlir/examples/toy/Ch6/toyc.cpp | 2 +-
mlir/examples/toy/Ch7/toyc.cpp | 2 +-
mlir/examples/transform-opt/mlir-transform-opt.cpp | 2 +-
7 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/mlir/examples/toy/Ch2/toyc.cpp b/mlir/examples/toy/Ch2/toyc.cpp
index 89eb8ef803ff53..79fe1297ecd271 100644
--- a/mlir/examples/toy/Ch2/toyc.cpp
+++ b/mlir/examples/toy/Ch2/toyc.cpp
@@ -87,7 +87,7 @@ static int dumpMLIR() {
if (!module)
return 1;
- module->print(llvm::errs(), mlir::OpPrintingFlags().useLocalScope());
+ module->print(llvm::errs());
llvm::errs() << "\n";
return 0;
}
@@ -110,7 +110,7 @@ static int dumpMLIR() {
return 3;
}
- module->print(llvm::errs(), mlir::OpPrintingFlags().useLocalScope());
+ module->print(llvm::errs());
llvm::errs() << "\n";
return 0;
}
diff --git a/mlir/examples/toy/Ch3/toyc.cpp b/mlir/examples/toy/Ch3/toyc.cpp
index 84d55dd89e9675..5e0c15cec5a3d5 100644
--- a/mlir/examples/toy/Ch3/toyc.cpp
+++ b/mlir/examples/toy/Ch3/toyc.cpp
@@ -131,7 +131,7 @@ static int dumpMLIR() {
return 4;
}
- module->print(llvm::errs(), mlir::OpPrintingFlags().useLocalScope());
+ module->print(llvm::errs());
llvm::errs() << "\n";
return 0;
}
diff --git a/mlir/examples/toy/Ch4/toyc.cpp b/mlir/examples/toy/Ch4/toyc.cpp
index 265de64c70feef..10400e437c9d12 100644
--- a/mlir/examples/toy/Ch4/toyc.cpp
+++ b/mlir/examples/toy/Ch4/toyc.cpp
@@ -140,7 +140,7 @@ static int dumpMLIR() {
return 4;
}
- module->print(llvm::errs(), mlir::OpPrintingFlags().useLocalScope());
+ module->print(llvm::errs());
llvm::errs() << "\n";
return 0;
}
diff --git a/mlir/examples/toy/Ch5/toyc.cpp b/mlir/examples/toy/Ch5/toyc.cpp
index d119bd67fec4dc..efaa327eb853a8 100644
--- a/mlir/examples/toy/Ch5/toyc.cpp
+++ b/mlir/examples/toy/Ch5/toyc.cpp
@@ -168,7 +168,7 @@ static int dumpMLIR() {
if (mlir::failed(pm.run(*module)))
return 4;
- module->print(llvm::errs(), mlir::OpPrintingFlags().useLocalScope());
+ module->print(llvm::errs());
llvm::errs() << "\n";
return 0;
}
diff --git a/mlir/examples/toy/Ch6/toyc.cpp b/mlir/examples/toy/Ch6/toyc.cpp
index af7405920a55de..9c250c9daed39f 100644
--- a/mlir/examples/toy/Ch6/toyc.cpp
+++ b/mlir/examples/toy/Ch6/toyc.cpp
@@ -315,7 +315,7 @@ int main(int argc, char **argv) {
// If we aren't exporting to non-mlir, then we are done.
bool isOutputingMLIR = emitAction <= Action::DumpMLIRLLVM;
if (isOutputingMLIR) {
- module->print(llvm::errs(), mlir::OpPrintingFlags().useLocalScope());
+ module->print(llvm::errs());
llvm::errs() << "\n";
return 0;
}
diff --git a/mlir/examples/toy/Ch7/toyc.cpp b/mlir/examples/toy/Ch7/toyc.cpp
index f153a784a62864..4c897333551b11 100644
--- a/mlir/examples/toy/Ch7/toyc.cpp
+++ b/mlir/examples/toy/Ch7/toyc.cpp
@@ -316,7 +316,7 @@ int main(int argc, char **argv) {
// If we aren't exporting to non-mlir, then we are done.
bool isOutputingMLIR = emitAction <= Action::DumpMLIRLLVM;
if (isOutputingMLIR) {
- module->print(llvm::errs(), mlir::OpPrintingFlags().useLocalScope());
+ module->print(llvm::errs());
llvm::errs() << "\n";
return 0;
}
diff --git a/mlir/examples/transform-opt/mlir-transform-opt.cpp b/mlir/examples/transform-opt/mlir-transform-opt.cpp
index bdd4ce0185cfef..2599f5e50f51e2 100644
--- a/mlir/examples/transform-opt/mlir-transform-opt.cpp
+++ b/mlir/examples/transform-opt/mlir-transform-opt.cpp
@@ -309,7 +309,7 @@ static llvm::LogicalResult processPayloadBuffer(
// If requested, dump the combined transform module.
if (clOptions->dumpLibraryModule) {
- transformRoot->print(os, mlir::OpPrintingFlags().useLocalScope());
+ transformRoot->print(os);
os << "\n";
}
More information about the Mlir-commits
mailing list