Skip to content

Conversation

@pchen7e2
Copy link
Contributor

@pchen7e2 pchen7e2 commented Aug 21, 2025

There're places where a pointer instead of ProgramPoint object is passed to stream print <<:

https://github.com/pchen7e2/llvm-project/blob/4256d8229602eb08598761f211d54e719007b468/mlir/lib/Analysis/DataFlowFramework.cpp#L132-L133

and they'll be printed as pointer value. This PR converts them to object before passing to stream printers.

I have a random local IR and I call opt tool on it with -debug-only=dataflow.

Before:

Invoking 'mlir::dataflow::DeadCodeAnalysis' on: 0x51936d8
Invoking 'mlir::triton::(anonymous namespace)::AxisInfoAnalysis' on: 0x51936d8
Creating dependency between mlir::dataflow::PredecessorState of <before operation>:scf.yield %arg3 : i32
and mlir::dataflow::PredecessorState on 0x51936d8

After:

Invoking 'mlir::dataflow::DeadCodeAnalysis' on: <before operation>:scf.yield %arg3 : i32
Invoking 'mlir::triton::(anonymous namespace)::AxisInfoAnalysis' on: <before operation>:scf.yield %arg3 : i32
Creating dependency between mlir::dataflow::PredecessorState of <before operation>:scf.yield %arg3 : i32
and mlir::dataflow::PredecessorState on <before operation>:scf.yield %arg3 : i32

It's now calling point->print instead of printing the pointer address value.

@llvmbot llvmbot added the mlir label Aug 21, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 21, 2025

@llvm/pr-subscribers-mlir

Author: Peng Chen (pchen7e2)

Changes

There're places where a pointer instead of ProgramPoint object is passed to stream print &lt;&lt;:

https://github.com/pchen7e2/llvm-project/blob/4256d8229602eb08598761f211d54e719007b468/mlir/lib/Analysis/DataFlowFramework.cpp#L132-L133

so one override at L150 might not be sufficient to print it nicely.

I have a random local IR and I call opt tool on it with -debug-only=dataflow.

Before:

Invoking 'mlir::dataflow::DeadCodeAnalysis' on: 0x51936d8
Invoking 'mlir::triton::(anonymous namespace)::AxisInfoAnalysis' on: 0x51936d8
Creating dependency between mlir::dataflow::PredecessorState of &lt;before operation&gt;:scf.yield %arg3 : i32
and mlir::dataflow::PredecessorState on 0x51936d8

After:

Invoking 'mlir::dataflow::DeadCodeAnalysis' on: &lt;before operation&gt;:scf.yield %arg3 : i32
Invoking 'mlir::triton::(anonymous namespace)::AxisInfoAnalysis' on: &lt;before operation&gt;:scf.yield %arg3 : i32
Creating dependency between mlir::dataflow::PredecessorState of &lt;before operation&gt;:scf.yield %arg3 : i32
and mlir::dataflow::PredecessorState on &lt;before operation&gt;:scf.yield %arg3 : i32

It's now calling point-&gt;print instead of printing the pointer address value.


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

1 Files Affected:

  • (modified) mlir/include/mlir/Analysis/DataFlowFramework.h (+5)
diff --git a/mlir/include/mlir/Analysis/DataFlowFramework.h b/mlir/include/mlir/Analysis/DataFlowFramework.h
index caf978a51fd8e..88edfa624fa90 100644
--- a/mlir/include/mlir/Analysis/DataFlowFramework.h
+++ b/mlir/include/mlir/Analysis/DataFlowFramework.h
@@ -152,6 +152,11 @@ inline raw_ostream &operator<<(raw_ostream &os, const ProgramPoint &point) {
   return os;
 }
 
+inline raw_ostream &operator<<(raw_ostream &os, const ProgramPoint *point) {
+  point->print(os);
+  return os;
+}
+
 //===----------------------------------------------------------------------===//
 // GenericLatticeAnchor
 //===----------------------------------------------------------------------===//

@pchen7e2 pchen7e2 closed this Aug 21, 2025
@pchen7e2 pchen7e2 force-pushed the improve-dataflow-log branch from 4256d82 to 66850d0 Compare August 21, 2025 20:46
@pchen7e2 pchen7e2 reopened this Aug 21, 2025
@pchen7e2 pchen7e2 marked this pull request as draft August 22, 2025 16:35
@pchen7e2 pchen7e2 force-pushed the improve-dataflow-log branch from 9d93c44 to e5446db Compare August 22, 2025 16:51
@pchen7e2 pchen7e2 closed this Aug 22, 2025
@pchen7e2 pchen7e2 force-pushed the improve-dataflow-log branch from e5446db to e12689e Compare August 22, 2025 16:53
@pchen7e2 pchen7e2 reopened this Aug 22, 2025
@pchen7e2 pchen7e2 marked this pull request as ready for review August 22, 2025 17:02
@pchen7e2 pchen7e2 requested a review from joker-eph August 22, 2025 17:02
@joker-eph joker-eph merged commit 6896725 into llvm:main Aug 22, 2025
9 checks passed
@pchen7e2 pchen7e2 changed the title Support nice logging for ProgramPoint* in dataflow log Print ProgramPoint instead of pointer for better logging Aug 22, 2025
@pchen7e2 pchen7e2 deleted the improve-dataflow-log branch August 22, 2025 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants