diff options
author | Andrei Golubev <andrey.golubev@intel.com> | 2024-01-29 10:37:11 +0200 |
---|---|---|
committer | Tom Stellard <tstellar@redhat.com> | 2024-01-29 15:10:47 -0800 |
commit | 0680e84a3f2a366a860bd0491f490a2fba800313 (patch) | |
tree | 0d035220b8ab3cc44584fb253adc05b47faa7dae /mlir | |
parent | bdaf16d59f4a64529371cbe056245f6cc035d7cf (diff) | |
download | llvm-0680e84a3f2a366a860bd0491f490a2fba800313.zip llvm-0680e84a3f2a366a860bd0491f490a2fba800313.tar.gz llvm-0680e84a3f2a366a860bd0491f490a2fba800313.tar.bz2 |
[mlir] Revert to old fold logic in IR::Dialect::add{Types, Attributes}() (#79582)
Fold expressions on Clang are limited to 256 elements. This causes
compilation errors in cases when the amount of elements added exceeds
this limit. Side-step the issue by restoring the original trick that
would use the std::initializer_list. For the record, in our downstream
Clang 16 gives:
mlir/include/mlir/IR/Dialect.h:269:23: fatal error: instantiating fold
expression with 688 arguments exceeded expression nesting limit of 256
(addType<Args>(), ...);
Partially reverts 26d811b3ecd2fa1ca3d9b41e17fb42b8c7ad03d6.
Co-authored-by: Nikita Kudriavtsev <nikita.kudriavtsev@intel.com>
(cherry picked from commit e3a38a75ddc6ff00301ec19a0e2488d00f2cc297)
Diffstat (limited to 'mlir')
-rw-r--r-- | mlir/include/mlir/IR/Dialect.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/mlir/include/mlir/IR/Dialect.h b/mlir/include/mlir/IR/Dialect.h index 45f29f3..50f6f6d 100644 --- a/mlir/include/mlir/IR/Dialect.h +++ b/mlir/include/mlir/IR/Dialect.h @@ -281,7 +281,11 @@ protected: /// Register a set of type classes with this dialect. template <typename... Args> void addTypes() { - (addType<Args>(), ...); + // This initializer_list argument pack expansion is essentially equal to + // using a fold expression with a comma operator. Clang however, refuses + // to compile a fold expression with a depth of more than 256 by default. + // There seem to be no such limitations for initializer_list. + (void)std::initializer_list<int>{0, (addType<Args>(), 0)...}; } /// Register a type instance with this dialect. @@ -292,7 +296,11 @@ protected: /// Register a set of attribute classes with this dialect. template <typename... Args> void addAttributes() { - (addAttribute<Args>(), ...); + // This initializer_list argument pack expansion is essentially equal to + // using a fold expression with a comma operator. Clang however, refuses + // to compile a fold expression with a depth of more than 256 by default. + // There seem to be no such limitations for initializer_list. + (void)std::initializer_list<int>{0, (addAttribute<Args>(), 0)...}; } /// Register an attribute instance with this dialect. |