Gabe Black has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/34817 )

Change subject: base: Use M5_UNLIKELY for conditional panic, etc., macros.
......................................................................

base: Use M5_UNLIKELY for conditional panic, etc., macros.

panic_if and fail_if should happen at most once in any given simulation,
and warn_if, etc., should still not happen most of the time.

Change-Id: Iaa6cb03c11b86d84f51cc4738efb8f203de4201c
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/34817
Reviewed-by: Jason Lowe-Power <power...@gmail.com>
Maintainer: Jason Lowe-Power <power...@gmail.com>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/base/logging.hh
1 file changed, 5 insertions(+), 5 deletions(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/base/logging.hh b/src/base/logging.hh
index 7113af8..f56420b 100644
--- a/src/base/logging.hh
+++ b/src/base/logging.hh
@@ -196,7 +196,7 @@
  */
 #define panic_if(cond, ...)                                  \
     do {                                                     \
-        if ((cond)) {                                        \
+        if (M5_UNLIKELY(cond)) {                             \
             panic("panic condition " # cond " occurred: %s", \
                   csprintf(__VA_ARGS__));                    \
         }                                                    \
@@ -218,7 +218,7 @@
  */
 #define fatal_if(cond, ...)                                     \
     do {                                                        \
-        if ((cond)) {                                           \
+        if (M5_UNLIKELY(cond)) {                                \
             fatal("fatal condition " # cond " occurred: %s",    \
                   csprintf(__VA_ARGS__));                       \
         }                                                       \
@@ -262,13 +262,13 @@
  */
 #define warn_if(cond, ...) \
     do { \
-        if ((cond)) \
+        if (M5_UNLIKELY(cond)) \
             warn(__VA_ARGS__); \
     } while (0)

 #define warn_if_once(cond, ...) \
     do { \
-        if ((cond)) \
+        if (M5_UNLIKELY(cond)) \
             warn_once(__VA_ARGS__); \
     } while (0)
 /** @} */ // end of api_logger
@@ -291,7 +291,7 @@
 #else //!NDEBUG
 #define chatty_assert(cond, ...)                                        \
     do {                                                                \
-        if (!(cond))                                                    \
+        if (M5_UNLIKELY(!(cond)))                                       \
panic("assert(" # cond ") failed: %s", csprintf(__VA_ARGS__)); \
     } while (0)
 #endif // NDEBUG

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/34817
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Iaa6cb03c11b86d84f51cc4738efb8f203de4201c
Gerrit-Change-Number: 34817
Gerrit-PatchSet: 2
Gerrit-Owner: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Anthony Gutierrez <anthony.gutier...@amd.com>
Gerrit-Reviewer: Bobby R. Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Jason Lowe-Power <power...@gmail.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to