[Mlir-commits] [mlir] [mlir][LLVM] Add !invariant.group metadata to llvm.load and llvm.store (PR #115723)

Christian Ulmann llvmlistbot at llvm.org
Mon Nov 11 22:56:31 PST 2024


Dinistro wrote:

> Thanks for the comment. I'll resolve the reviews later.
> 
> A random question not really related to this PR: do we have a way to attach arbitrary LLVM metadata to an LLVM dialect operation? I noticed there is a !llvm.metadata type but I don't see how to make use of it.

I don't think that this type is used for anything generic. So far, there is no support for arbitrary LLVM metadata. I think there are two main concerns:

1. Metadata encodes arbitrary information, that only specific passes might understand. This is a bandaid solution for LLVM, as it does not allow proper extending of instructions. As we know, this has many flaws, like metadata getting lost along the way, because some pass isn't aware of it.
2. Importing and exporting is not well defined, as metadata has almost no structural restrictions. So even when we would support adding arbitrary metadata to operations in MLIR, the export would require a custom handling.

Note: This does *not* mean that custom information cannot be added to existing upstream operations. In our case, we use the custom attributes + "named discardable attributes" to attach additional information to things like functions. This can then be picked up by dialect specific extensions to the LLVM exporter, such that a custom attribute is converted into some specific metadata or function attribute.


https://github.com/llvm/llvm-project/pull/115723


More information about the Mlir-commits mailing list