[llvm] [MLGO] Model selection for models lowered through EmitC (PR #212650)

Paul Kirth via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 30 09:47:31 PDT 2026


================
@@ -1226,6 +1226,21 @@ set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_LIBRARY_DIR} )
 # For up-to-date instructions for installing the TFLite dependency, refer to
 # the bot setup script: https://github.com/google/ml-compiler-opt/blob/main/buildbot/buildbot_init.sh
 set(LLVM_HAVE_TFLITE "" CACHE BOOL "Use tflite")
+
+set(LLVM_MLGO_MODELS "" CACHE STRING "List of AOT MLGO models")
+set(LLVM_MLGO_MLIR_OPT "mlir-opt" CACHE STRING "Path or system binary name for mlir-opt")
+set(LLVM_MLGO_MLIR_TRANSLATE "mlir-translate" CACHE STRING "Path or system binary name for mlir-translate")
+
+if (NOT LLVM_MLGO_MODELS STREQUAL "")
+  set(LLVM_HAVE_EMITC_COMPILE "ON" CACHE BOOL "MLGO AOT models compiled with EmitC are available" FORCE)
+else()
+  set(LLVM_HAVE_EMITC_COMPILE "OFF" CACHE BOOL "MLGO AOT models compiled with EmitC are available" FORCE)
+endif()
----------------
ilovepi wrote:

Sorry, I guess I didn't clarify. I was a little surprised that this wasn't just set to be OFF, and LLVM_MLGO_MODELS didn't just override to ON. IMO, it seems pretty strange to control the default via another variable.  The pattern I see in this file is that some variables are only defined if another is set, e.g. we don't generate benchmarking variables if benchmarking is disabled. So, I'd suggest just defaulting it to OFF, and then letting users override. 

If you don't want that, and want the LLVM_MLGO_MODELS to completely control it, then I'd suggest it not be a cache variable at all you just set it directly based on LLVM_MLGO_MODELS being empty or not. The other option is to only define it (and default to ON) if you're in the mode that makes sense (.e.g. LLVM_ENABLE_MLGO_EMITC or whatever).

But code wise if you want to dynamically set the default (which I think is kind of bad for users), I'd say just make another variable and set it via that:

```cmake
set LLVM_HAVE_EMITC_COMPILE ${MLGO_MODEL_EMPTY} CACHE BOOL ...)
```

https://github.com/llvm/llvm-project/pull/212650


More information about the llvm-commits mailing list