Could you please tell me the right way to pass metadata to the LLVM dialect, so that it can finally translate to LLVM IR with the same effect?
I also checked LLVM metadata support in MLIR, but because I am using the LLVM dialect to translate to LLVMIR directly, it seems that I can’t rebind a customized LLVMTranslationInterface to llvm dialect again.
My answer is essentially the same as in the thread you linked - LLVM metadata support in MLIR - #2 by ftynse. We don’t want to have arbitrary unverified metadata in MLIR so there almost no mechanisms to attach just a blob. You would need to model your metadata somehow in MLIR and provide a translation for them. It is difficult to understand what exactly these metadata are given your code snippet (which is also why we want it to be modeled properly), I can only suppose it has something to do with NVidia GPUs and can live in the nvvm dialect. Please elaborate on what is being modeled and somebody may be able to help you.
It is actually possible to have a fully custom LLVMTranslationInterface and use it in an out-of-tree binary as long as it doesn’t call mlir::registerLLVMDialectTranslation to register the default interface implementation. (You cannot convince mlir-translate to use the non-default implementation though.) However, I doubt this is necessary.