How to use llvm.metadata?

I tried to use the ‘llvm.metadata’ Operation like this:
%1 = llvm.metadata @metadata { llvm.access_group @group1 llvm.access_group @group2 llvm.return }
but got an error:
error: custom op 'llvm.metadata' is unknown

Which version of MLIR are you using? At git HEAD,

llvm.metadata @metadata {
  llvm.access_group @group1
  llvm.access_group @group2

parses just fine. Note that this operation does not define SSA values, so %1 is incorrect.

I’m using llvm version 12.0.0, which does not contain ’ ::mlir::LLVM::MetadataOp’. And for some reason, I can only use this version now. What shoud I do to be able to use ‘llvm.metadata’?

You need to use a more recent version of MLIR. Follow this Getting Started - MLIR to get one from Github.

The latest version is 12.0.1,Is there a big difference between version 12.0.1 and version 12.0.0 about metadata? As I can use version 12.0.0, what changes should I make in this version to enable to use llvm.metadata?

Please follow the instructions posted above to get a version from git. A “stable” version of LLVM just contains a snapshot of MLIR code at a given time, there is no guarantee of some operations being available or some features being anyhow complete.