25 Commits

Author SHA1 Message Date
Mehdi Amini
9c82f87aec
Introduce a "log level" support for DEBUG_TYPE (#150855)
This allows to set an optional integer level for a given debug type. The
string format is `type[:level]`, and the integer is interpreted as such:

- if not provided: all debugging for this debug type is enabled.
- if >0: all debug that is < to the level is enabled.
- if 0: same as for >0 but also does not disable the other debug-types,
it acts as a negative filter.

The LDBG() macro is updated to accept an optional log level to
illustrate the feature. Here is the expected behavior:

LDBG() << "A"; // Identical to LDBG(1) << "A";
LDBG(2) << "B";

With `--debug-only=some_type`: we'll see A and B in the output.  
With `--debug-only=some_type:1`: we'll see A but not B in the output. 
With `--debug-only=some_type:2`: we'll see A and B in the output. (same
with any level above 2)
With `--debug-only=some_type:0`: we'll see neither A nor B in the
output, but we'll see any other logging for other debug types.
2025-07-28 18:10:36 +02:00
Mehdi Amini
789fcef805
[MLIR] Migrate some "transform dialect" source to use the standard LDBG macro (NFC) (#150695) 2025-07-27 20:19:23 +02:00
Mehdi Amini
9e09c4dd52 [MLIR] Fix release build: the definition for the FULL_LDBG macro was incorrect 2025-07-25 14:12:51 -07:00
Benoit Jacob
04a44fef1f
[MLIR] Fix release build: FULL_LDBG macro was incorrect when NDEBUG is defined (#150698)
DEBUGLOG_WITH_STREAM_AND_TYPE is an internal implementation detail of
LDBG in DebugLog.h. When NDEBUG is defined,
DEBUGLOG_WITH_STREAM_AND_TYPE is not defined at all.

Signed-off-by: Benoit Jacob <jacob.benoit.1@gmail.com>
2025-07-25 22:52:45 +02:00
Jacques Pienaar
07967d4af8
[mlir] Switch to new LDBG macro (#150616)
Change local variants to use new central one.
2025-07-25 18:22:46 +02:00
Kazu Hirata
0925d7572a
[mlir] Remove unused includes (NFC) (#150266)
These are identified by misc-include-cleaner.  I've filtered out those
that break builds.  Also, I'm staying away from llvm-config.h,
config.h, and Compiler.h, which likely cause platform- or
compiler-specific build failures.
2025-07-23 15:18:53 -07:00
Kazu Hirata
7e4e33e90e
[mlir] Use llvm::is_contained (NFC) (#140986) 2025-05-21 20:32:28 -07:00
Kazu Hirata
921d162460
[mlir] Remove unused local variables (NFC) (#138642) 2025-05-06 07:55:50 -07:00
Jakub Kuderski
198c5dac37
[mlir][transform] Clean up prints. NFC. (#136401)
Use `llvm::interleaved` from #135517 to simplify printing.
2025-04-19 12:11:06 -04:00
MaheshRavishankar
205c5325b3
[mlir] Add a utility method to move operation dependencies. (#129975)
The added utility method moves all SSA values that an operation depends
upon before an insertion point. This is useful during transformations
where such movements might make transformations (like fusion) more
powerful.

To test the operation add a transform dialect op that calls the move
operation. To be able to capture the `notifyMatchFailure` messages from
the transformation and to report/check these in the test modify the
`ErrorCheckingTrackingListener` to capture the last match failure
notification.

---------

Signed-off-by: MaheshRavishankar <mahesh.ravishankar@gmail.com>
2025-03-10 20:23:08 -07:00
Kazu Hirata
129f1001c3
[Dialect] Migrate away from PointerUnion::{is,get} (NFC) (#120818)
Note that PointerUnion::{is,get} have been soft deprecated in
PointerUnion.h:

  // FIXME: Replace the uses of is(), get() and dyn_cast() with
  //        isa<T>, cast<T> and the llvm::dyn_cast<T>

I'm not touching PointerUnion::dyn_cast for now because it's a bit
complicated; we could blindly migrate it to dyn_cast_if_present, but
we should probably use dyn_cast when the operand is known to be
non-null.
2024-12-21 08:17:51 -08:00
Mehdi Amini
6c7a3f80e7
Fix LLVM_ENABLE_ABI_BREAKING_CHECKS macro check: use #if instead of #ifdef (#110938)
This macros is always defined: either 0 or 1. The correct pattern is to
use #if.

Re-apply #110185 with more fixes for debug build with the ABI breaking
checks disabled.
2024-10-03 01:24:14 +02:00
Christopher Di Bella
45ad1ac4a3
Revert "Fix LLVM_ENABLE_ABI_BREAKING_CHECKS macro check: use #if inst… (#110923)
…ead of #ifdef (#110883)"

This reverts commit 1905cdbf4ef15565504036c52725cb0622ee64ef, which
causes lots of failures where LLVM doesn't have the right header guards.
The errors can be seen on
[BuildKite](https://buildkite.com/llvm-project/upstream-bazel/builds/112362#01924eae-231c-4d06-ba87-2c538cf40e04),
where the source uses `#ifndef NDEBUG`, but the content in question is
defined when `LLVM_ENABLE_ABI_BREAKING_CHECKS == 1`.

For example, `llvm/include/llvm/Support/GenericDomTreeConstruction.h`
has the following:

```cpp
// Helper struct used during edge insertions.
struct InsertionInfo {
  // ...
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
  SmallVector<TreeNodePtr, 8> VisitedUnaffected;
#endif
};

// ...

InsertionInfo II;
// ...
#ifndef NDEBUG
            II.VisitedUnaffected.push_back(SuccTN);
#endif
```
2024-10-02 13:54:09 -07:00
Mehdi Amini
1905cdbf4e
Fix LLVM_ENABLE_ABI_BREAKING_CHECKS macro check: use #if instead of #ifdef (#110883)
This macros is always defined: either 0 or 1. The correct pattern is to
use #if.

Reapply https://github.com/llvm/llvm-project/pull/110185 with fixes.
2024-10-02 18:43:16 +02:00
Mehdi Amini
68ddd6c80e
Revert "Fix LLVM_ENABLE_ABI_BREAKING_CHECKS macro check: use #if instead of #ifdef" (#110310)
Reverts llvm/llvm-project#110185

There are inconsistencies in some of these macros, which unfortunately
isn't caught by a single upstream bot.
2024-09-27 20:34:14 +02:00
Mehdi Amini
5e98136679
Fix LLVM_ENABLE_ABI_BREAKING_CHECKS macro check: use #if instead of #ifdef (#110185)
This macros is always defined: either 0 or 1. The correct pattern is to
use #if.
2024-09-27 11:52:22 +02:00
Jianjian Guan
e323b40bf1
[NFC][mlir] Simplify code (#108346) 2024-09-13 10:31:30 +08:00
Amy Wang
6634d44e5e
[MLIR][Transform] Allow stateInitializer and stateExporter for applyTransforms (#101186)
This is discussed in RFC:

https://discourse.llvm.org/t/rfc-making-the-constructor-of-the-transformstate-class-protected/80377
2024-09-09 10:57:13 -04:00
Kazu Hirata
5262865aac
[mlir] Construct SmallVector with ArrayRef (NFC) (#101896) 2024-08-04 11:43:05 -07:00
Ramkumar Ramachandra
db791b278a
mlir/LogicalResult: move into llvm (#97309)
This patch is part of a project to move the Presburger library into
LLVM.
2024-07-02 10:42:33 +01:00
Kazu Hirata
b7b337fb91
[mlir] Use llvm::unique (NFC) (#96415) 2024-06-24 11:54:02 -07:00
donald chen
2c1ae801e1
[mlir][side effect] refactor(*): Include more precise side effects (#94213)
This patch adds more precise side effects to the current ops with memory
effects, allowing us to determine which OpOperand/OpResult/BlockArgument
the
operation reads or writes, rather than just recording the reading and
writing
of values. This allows for convenient use of precise side effects to
achieve
analysis and optimization.

Related discussions:
https://discourse.llvm.org/t/rfc-add-operandindex-to-sideeffect-instance/79243
2024-06-19 22:10:34 +08:00
Oleksandr "Alex" Zinenko
e4b04b391f
[mlir] make transform.foreach_match forward arguments (#89920)
It may be useful to have access to additional handles or parameters when
performing matches and actions in `foreach_match`, for example, to
parameterize the matcher by rank or restrict it in a non-trivial way.
Enable `foreach_match` to forward additional handles from operands to
matcher symbols and from action symbols to results.
2024-05-03 10:15:44 +02:00
Oleksandr "Alex" Zinenko
91856b34e3
[mlir] move MatchOpInterface under Transform/Interfaces (#86899)
This is similar to the TransformOpInterface move.
2024-03-28 14:00:22 +01:00
Oleksandr "Alex" Zinenko
5a9bdd85ee
[mlir] split transform interfaces into a separate library (#85221)
Transform interfaces are implemented, direction or via extensions, in
libraries belonging to multiple other dialects. Those dialects don't
need to depend on the non-interface part of the transform dialect, which
includes the growing number of ops and transitive dependency footprint.

Split out the interfaces into a separate library. This in turn requires
flipping the dependency from the interface on the dialect that has crept
in because both co-existed in one library. The interface shouldn't
depend on the transform dialect either.

As a consequence of splitting, the capability of the interpreter to
automatically walk the payload IR to identify payload ops of a certain
kind based on the type used for the entry point symbol argument is
disabled. This is a good move by itself as it simplifies the interpreter
logic. This functionality can be trivially replaced by a
`transform.structured.match` operation.
2024-03-20 22:15:17 +01:00