From 19cd437221ee09436d9ddb1a3f1d39443c447992 Mon Sep 17 00:00:00 2001 From: Scott Wolchok Date: Tue, 9 Apr 2024 11:16:40 -0700 Subject: [PATCH] [executorch] Use __ET_UNLIKELY in assertion macros It is supposed to be unlikely for assert/check conditions to fail; let's tell the compiler about that. Differential Revision: [D55929730](https://our.internmc.facebook.com/intern/diff/D55929730/) [ghstack-poisoned] --- runtime/platform/assert.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/platform/assert.h b/runtime/platform/assert.h index 8728e6a8d74..9222b8ed7fa 100644 --- a/runtime/platform/assert.h +++ b/runtime/platform/assert.h @@ -35,7 +35,7 @@ */ #define ET_CHECK_MSG(_cond, _format, ...) \ ({ \ - if (!(_cond)) { \ + if __ET_UNLIKELY (!(_cond)) { \ ET_ASSERT_MESSAGE_EMIT(" (%s): " _format, #_cond, ##__VA_ARGS__); \ torch::executor::runtime_abort(); \ } \ @@ -49,7 +49,7 @@ */ #define ET_CHECK(_cond) \ ({ \ - if (!(_cond)) { \ + if __ET_UNLIKELY (!(_cond)) { \ ET_ASSERT_MESSAGE_EMIT(": %s", #_cond); \ torch::executor::runtime_abort(); \ } \