Failed to satisfy constraint: flat symbol reference attribut

I’ve recently been building a new IR using MLIR, but it looks like I’m running into some problems.The IR I created is similar to a function call.So I used FlatSymbolRefAttr(referenced some other code).When I finished writing the parser(because of the complexity of the call form, I chose to implement the parser myself.) for the corresponding op. I got the following error message.

xxxop attribute 'callee' failed to satisfy constraint: flat symbol reference attribute
  • I know maybe there is a symbol verification somewhere. So I let hasVerifier = 1; and then validate inside, but it still doesn’t help.
  • Another question. What is the difference between SymbolRefAttr and FlatSymbolRefAttr?
    I looked up the relevant information, my understanding is that if it is SymbolRefAttr, then a function can refer to the symbols in another function, for FlatSymbolRefAttr, a function can only refer to the symbols in the current function. I don’t know if I understand it right.

I hope someone can help me with my questions.Thanks!

FlatSymbolRefAttr is a specific attribute, is your parser creating the callee attribute using this class?

1 Like

Thank you! This problem is solved .Can you answer the question What is the difference between SymbolRefAttr and FlatSymbolRefAttr?I’m confused about the exact use of both. :smiley:

Have you looked into the FlatSymbolRef class? llvm-project/mlir/include/mlir/IR/BuiltinAttributes.h at main · llvm/llvm-project · GitHub

Also the online doc for symbol ref: Builtin Dialect - MLIR ? It explains what is a SymbolRef in terms of FlatSymbolRef.

Thank you.I didn’t check Builtin Dialect ,I’ve checked all the other information and I think it’s much clearer now. :smiley: