[Mlir-commits] [mlir] [mlir][async] Avoid crash when not using `func.func` (PR #72801)
Rik Huijzer
llvmlistbot at llvm.org
Mon Nov 20 10:17:49 PST 2023
================
@@ -1143,6 +1143,8 @@ void OpEmitter::genAttrNameGetters() {
const char *const getAttrName = R"(
assert(index < {0} && "invalid attribute index");
assert(name.getStringRef() == getOperationName() && "invalid operation name");
+ assert(!name.getAttributeNames().empty() && "empty attribute names. Is a new "
----------------
rikhuijzer wrote:
I was wondering about that too. The attribute names are all known at compile time, so you would guess that `getFunctionTypeAttrName` (which figures out the name of the attribute `function_type`) can directly return the result. However, `getFunctionTypeAttrName` returns not only the name but also some context. I've tried passing the name as string instead of an `OperationName`, but that will crash since, if I remember correctly, the `FuncOp` could not be created since it was an unregistered op. So the fallback to (static?) `OpTy::getAttributeNames` is probably not gonna work.
Returning a `nullptr` for `getAttributeNames` sounds like something that may work.
https://github.com/llvm/llvm-project/pull/72801
More information about the Mlir-commits
mailing list