[llvm] [MLGO] Model selection for models lowered through EmitC (PR #212650)
ioana ghiban via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 5 04:45:58 PDT 2026
ioghiban wrote:
I tried building locally via a similar cmake config to what you suggested. I believe the MLIR pipeline in llvm/cmake/modules/MLGOLower.cmake is incompatible with how `wrap-emitc-func-in-class` is expecting its args.
For example, `Model1` is inserted by CMake string substitution:
```cmake
set(CLASS_NAME "Model${MODEL_INDEX}")
```
https://github.com/llvm/llvm-project/pull/212650/changes#diff-fb2d8944b8c7e644dff744ca1d14e7a7ce15aac1f9f59453bbc0c0ea44127053R50
So `mlir-opt` receives:
```bash
--pass-pipeline=builtin.module(...,wrap-emitc-func-in-class{class-name-format=Model1},...)
```
The pass then effectively executes:
```cpp
llvm::formatv("Model1", funcOp.getName());
```
https://github.com/llvm/llvm-project/blob/main/mlir/lib/Dialect/EmitC/Transforms/WrapFuncInClass.cpp#L81
That fails because "Model1" has zero placeholders but one argument is supplied.
It should receive:
```bash
wrap-emitc-func-in-class{class-name-format=Model1{0:0}}
```
I'd either make the formatter more loose to allow unused arguments and update the option description to say the function-name placeholder is optional.
A simpler workaround is using:
```cmake
"wrap-emitc-func-in-class{class-name-format=${CLASS_NAME}{0:0}}"
```
in the pass pipeline. The first fix may be cleaner.
https://github.com/llvm/llvm-project/pull/212650
More information about the llvm-commits
mailing list