diff --git a/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp b/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp index 4f0fab8e58bf8..3fa359d89ce2b 100644 --- a/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp +++ b/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp @@ -72,7 +72,7 @@ static cl::opt TrainingLog( "regalloc-training-log", cl::Hidden, cl::desc("Training log for the register allocator eviction model")); -static cl::opt ModelUnderTraining( +cl::opt ModelUnderTraining( "regalloc-model", cl::Hidden, cl::desc("The model being trained for register allocation eviction")); diff --git a/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp b/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp index a1dccc4d59723..cf5f760afbe51 100644 --- a/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp +++ b/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp @@ -44,6 +44,10 @@ static cl::opt EnableLocalReassignment( "may be compile time intensive"), cl::init(false)); +#ifdef LLVM_HAVE_TFLITE +extern cl::opt ModelUnderTraining; +#endif // #ifdef LLVM_HAVE_TFLITE + namespace llvm { cl::opt EvictInterferenceCutoff( "regalloc-eviction-max-interference-cutoff", cl::Hidden, @@ -85,6 +89,14 @@ class DefaultEvictionAdvisorAnalysis final if (NotAsRequested) M.getContext().emitError("Requested regalloc eviction advisor analysis " "could not be created. Using default"); + +#ifdef LLVM_HAVE_TFLITE + if (!ModelUnderTraining.empty()) + M.getContext().emitError( + "A model has been passed in, but the default eviction advisor " + "analysis was requested. The model will not be used."); +#endif // #ifdef LLVM_HAVE_TFLITE + return RegAllocEvictionAdvisorAnalysis::doInitialization(M); } const bool NotAsRequested; diff --git a/llvm/test/CodeGen/MLRegAlloc/dev-mode-default-advisor-model-error.ll b/llvm/test/CodeGen/MLRegAlloc/dev-mode-default-advisor-model-error.ll new file mode 100644 index 0000000000000..e88046d32ef76 --- /dev/null +++ b/llvm/test/CodeGen/MLRegAlloc/dev-mode-default-advisor-model-error.ll @@ -0,0 +1,14 @@ +; REQUIRES: have_tflite +; REQUIRES: x86_64-linux +; +; Checking that if we specify a model, but do not specify the development +; advisor, we get an error. +; +; RUN: not llc -mtriple=x86_64-linux-unknown -regalloc=greedy -regalloc-enable-advisor=default \ +; RUN: -regalloc-model=/model_foo %s -o /dev/null 2>&1 | FileCheck %s + +; CHECK: A model has been passed in, but the default eviction advisor analysis was requested. The model will not be used. + +define i32 @foo() { + ret i32 0 +}