Skip to content

[MLGO] Error if default eviction advisor is requested with model #102409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static cl::opt<std::string> TrainingLog(
"regalloc-training-log", cl::Hidden,
cl::desc("Training log for the register allocator eviction model"));

static cl::opt<std::string> ModelUnderTraining(
cl::opt<std::string> ModelUnderTraining(
"regalloc-model", cl::Hidden,
cl::desc("The model being trained for register allocation eviction"));

Expand Down
12 changes: 12 additions & 0 deletions llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ static cl::opt<bool> EnableLocalReassignment(
"may be compile time intensive"),
cl::init(false));

#ifdef LLVM_HAVE_TFLITE
extern cl::opt<std::string> ModelUnderTraining;
#endif // #ifdef LLVM_HAVE_TFLITE

namespace llvm {
cl::opt<unsigned> EvictInterferenceCutoff(
"regalloc-eviction-max-interference-cutoff", cl::Hidden,
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Loading