Skip to content

Commit

Permalink
[nfc][mlgo] Make error message macro
Browse files Browse the repository at this point in the history
`llvm_unreachable` is itself a macro, so using a constant for its
message renders that constant unused in non-debug builds.
  • Loading branch information
mtrofin committed Feb 9, 2022
1 parent 9611282 commit 62a775f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions llvm/include/llvm/Analysis/ReleaseModeModelRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,18 @@ class ReleaseModeModelRunner final : public MLModelRunner {
/// its `TGen` parameter. Useful to avoid conditional compilation complexity, as
/// a compile-time replacement for a real AOT-ed model.
class NoopSavedModelImpl final {
const char *ErrMsg = "The mock AOT-ed saved model is a compile-time stub and "
"should not be called.";
#define NOOP_MODEL_ERRMSG \
"The mock AOT-ed saved model is a compile-time stub and should not be " \
"called."

public:
NoopSavedModelImpl() = default;
int LookupArgIndex(const std::string &) { llvm_unreachable(ErrMsg); }
int LookupResultIndex(const std::string &) { llvm_unreachable(ErrMsg); }
void Run() { llvm_unreachable(ErrMsg); }
void *result_data(int) { llvm_unreachable(ErrMsg); }
void *arg_data(int) { llvm_unreachable(ErrMsg); }
int LookupArgIndex(const std::string &) { llvm_unreachable(NOOP_MODEL_ERRMSG); }
int LookupResultIndex(const std::string &) { llvm_unreachable(NOOP_MODEL_ERRMSG); }
void Run() { llvm_unreachable(NOOP_MODEL_ERRMSG); }
void *result_data(int) { llvm_unreachable(NOOP_MODEL_ERRMSG); }
void *arg_data(int) { llvm_unreachable(NOOP_MODEL_ERRMSG); }
#undef NOOP_MODEL_ERRMSG
};
} // namespace llvm

Expand Down

0 comments on commit 62a775f

Please sign in to comment.