[llvm] 62a775f - [nfc][mlgo] Make error message macro

Mircea Trofin via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 9 07:27:28 PST 2022


Author: Mircea Trofin
Date: 2022-02-09T07:27:21-08:00
New Revision: 62a775f1eaa737e5c9363f77bf48f44c8b110419

URL: https://github.com/llvm/llvm-project/commit/62a775f1eaa737e5c9363f77bf48f44c8b110419
DIFF: https://github.com/llvm/llvm-project/commit/62a775f1eaa737e5c9363f77bf48f44c8b110419.diff

LOG: [nfc][mlgo] Make error message macro

`llvm_unreachable` is itself a macro, so using a constant for its
message renders that constant unused in non-debug builds.

Added: 
    

Modified: 
    llvm/include/llvm/Analysis/ReleaseModeModelRunner.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Analysis/ReleaseModeModelRunner.h b/llvm/include/llvm/Analysis/ReleaseModeModelRunner.h
index 152d3e5fa313e..22d1628fb2428 100644
--- a/llvm/include/llvm/Analysis/ReleaseModeModelRunner.h
+++ b/llvm/include/llvm/Analysis/ReleaseModeModelRunner.h
@@ -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
 


        


More information about the llvm-commits mailing list