[Mlir-commits] [mlir] [mlir-tblgen] Only create body for unpruned create (PR #166019)
Hsiang-Chieh Tsou
llvmlistbot at llvm.org
Sat Nov 1 17:33:15 PDT 2025
================
@@ -2632,11 +2632,13 @@ void OpEmitter::genInlineCreateBody(
interleaveComma(nonBuilderStateArgsList, nonBuilderStateArgsOS);
nonBuilderStateArgs = ", " + nonBuilderStateArgs;
}
- cWithLoc->body() << llvm::formatv(inlineCreateBody, locParamName,
- nonBuilderStateArgs,
- opClass.getClassName());
- cImplicitLoc->body() << llvm::formatv(inlineCreateBodyImplicitLoc,
- nonBuilderStateArgs);
+ if (cWithLoc)
+ cWithLoc->body() << llvm::formatv(inlineCreateBody, locParamName,
+ nonBuilderStateArgs,
+ opClass.getClassName());
+ if (cImplicitLoc)
+ cImplicitLoc->body() << llvm::formatv(inlineCreateBodyImplicitLoc,
+ nonBuilderStateArgs);
----------------
hsjts0u wrote:
I can repro but it is kind of awkward. I hit this https://github.com/hsjts0u/llvm-project/blob/main/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp#L3121 before I hit the segfault. Something like this would segfault if that line is commented out or the `if (body)` check is added back.
```
def ReproOp : NS_Op<"repro", []> {
let arguments = (ins
SymbolNameAttr:$sym_name,
TypeAttrOf<FunctionType>:$function_type,
OptionalAttr<DictArrayAttr>:$arg_attrs,
OptionalAttr<DictArrayAttr>:$res_attrs,
OptionalAttr<UnitAttr>:$unit
);
let regions = (region AnyRegion:$body);
let builders = [
OpBuilder<(ins
"StringRef":$name, "FunctionType":$type,
CArg<"ArrayRef<DictionaryAttr>", "{}">:$argAttrs,
CArg<"ArrayRef<DictionaryAttr>", "{}">:$resultAttrs)
>,
OpBuilder<(ins
"StringRef":$name, "FunctionType":$type)
>];
}
```
https://github.com/llvm/llvm-project/pull/166019
More information about the Mlir-commits
mailing list