LLVM metadata support in MLIR

MLIR generally takes a much more structured approach to metadata-like information than LLVM does, in particular by using a wide and structured attribute system. Therefore, we add support for LLVM metadata equivalents on a case-by-case need-driven basis. Using an opaque string metadata is exactly the kind of situation we want to avoid because of associated development and runtime costs.

If you need metadata that is part of LLVM IR specification, consider adding it to relevant operations and/or the LLVM dialect itself using appropriate attribute kinds and providing verifiers. If you need custom metadata, introduce in a dialect of your own, again using the appropriate attribute kinds and providing verifiers. The translation infrastructure now has support to process foreign-dialect attributes on LLVM operations in order to modify the LLVM IR emitted when translating the operation - llvm-project/LLVMTranslationInterface.h at main · llvm/llvm-project · GitHub - that can be used to forward this metadata to LLVM IR.