From c8cde1fefa341af95bc6aa66d5a4f82261d7c002 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 17 Sep 2020 20:50:27 -0700 Subject: [PATCH] base: Use M5_UNLIKELY with conditional DPRINTF family functions. Most DPRINTFs will be skipped over most of the time, and when they aren't they'll already have overhead from string handling, output to the console and/or a file, etc, which will drown out the behavior of a branch. Change-Id: I5475d7b5add63b44f60c0a1d46b4b14e6bf30fd3 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/34818 Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power Tested-by: kokoro --- src/base/trace.hh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/base/trace.hh b/src/base/trace.hh index 3d8752cfc..aafb9c8e4 100644 --- a/src/base/trace.hh +++ b/src/base/trace.hh @@ -182,14 +182,14 @@ class Named #define DDUMP(x, data, count) do { \ using namespace Debug; \ - if (DTRACE(x)) \ + if (M5_UNLIKELY(DTRACE(x))) \ Trace::getDebugLogger()->dump( \ curTick(), name(), data, count, #x); \ } while (0) #define DPRINTF(x, ...) do { \ using namespace Debug; \ - if (DTRACE(x)) { \ + if (M5_UNLIKELY(DTRACE(x))) { \ Trace::getDebugLogger()->dprintf_flag( \ curTick(), name(), #x, __VA_ARGS__); \ } \ @@ -197,7 +197,7 @@ class Named #define DPRINTFS(x, s, ...) do { \ using namespace Debug; \ - if (DTRACE(x)) { \ + if (M5_UNLIKELY(DTRACE(x))) { \ Trace::getDebugLogger()->dprintf_flag( \ curTick(), s->name(), #x, __VA_ARGS__); \ } \ @@ -205,7 +205,7 @@ class Named #define DPRINTFR(x, ...) do { \ using namespace Debug; \ - if (DTRACE(x)) { \ + if (M5_UNLIKELY(DTRACE(x))) { \ Trace::getDebugLogger()->dprintf_flag( \ (Tick)-1, std::string(), #x, __VA_ARGS__); \ } \ -- 2.30.2