[compiler-rt] 1f0834a - [NFC][sanitizer] Use `UNLIKELY` in VReport/VPrintf (#104403)

via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 15 16:05:06 PDT 2024


Author: Vitaly Buka
Date: 2024-08-15T16:05:03-07:00
New Revision: 1f0834ad7192d8a73bbf15bb4ad8aa71f9a92ec6

URL: https://github.com/llvm/llvm-project/commit/1f0834ad7192d8a73bbf15bb4ad8aa71f9a92ec6
DIFF: https://github.com/llvm/llvm-project/commit/1f0834ad7192d8a73bbf15bb4ad8aa71f9a92ec6.diff

LOG: [NFC][sanitizer] Use `UNLIKELY` in VReport/VPrintf (#104403)

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_common.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.h b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
index 2428a8cd14794..182dc8f26c88f 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
@@ -239,13 +239,15 @@ void RemoveANSIEscapeSequencesFromString(char *buffer);
 void Printf(const char *format, ...) FORMAT(1, 2);
 void Report(const char *format, ...) FORMAT(1, 2);
 void SetPrintfAndReportCallback(void (*callback)(const char *));
-#define VReport(level, ...)                                              \
-  do {                                                                   \
-    if ((uptr)Verbosity() >= (level)) Report(__VA_ARGS__); \
+#define VReport(level, ...)                     \
+  do {                                          \
+    if (UNLIKELY((uptr)Verbosity() >= (level))) \
+      Report(__VA_ARGS__);                      \
   } while (0)
-#define VPrintf(level, ...)                                              \
-  do {                                                                   \
-    if ((uptr)Verbosity() >= (level)) Printf(__VA_ARGS__); \
+#define VPrintf(level, ...)                     \
+  do {                                          \
+    if (UNLIKELY((uptr)Verbosity() >= (level))) \
+      Printf(__VA_ARGS__);                      \
   } while (0)
 
 // Lock sanitizer error reporting and protects against nested errors.


        


More information about the llvm-commits mailing list