[compiler-rt] [compiler-rt] Remove redundant checks. (PR #95753)

Dmitriy Chestnykh via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 17 01:55:38 PDT 2024


https://github.com/chestnykh updated https://github.com/llvm/llvm-project/pull/95753

>From d252e9d1599fd39b973cb5eac7568ddb6075dc8e Mon Sep 17 00:00:00 2001
From: Dmitry Chestnykh <dm.chestnykh at gmail.com>
Date: Mon, 17 Jun 2024 11:26:43 +0300
Subject: [PATCH] [compiler-rt] Remove redundant checks.

Since `__sancov_default_options` and `__asan_default_suppressions`
are weak definitions, not weak references (declarations) the checks
of equality of addresses of these symbols to zero is not needed.
So we can completely remove `MaybeCallSancovDefaultOptions`
and use `__sancov_default_options` instead directly.
gcc-14 emits `-Waddress` warning to such checks.
---
 compiler-rt/lib/asan/asan_suppressions.cpp        | 3 +--
 compiler-rt/lib/sanitizer_common/sancov_flags.cpp | 6 +-----
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/compiler-rt/lib/asan/asan_suppressions.cpp b/compiler-rt/lib/asan/asan_suppressions.cpp
index e71d231821866..6cee674960395 100644
--- a/compiler-rt/lib/asan/asan_suppressions.cpp
+++ b/compiler-rt/lib/asan/asan_suppressions.cpp
@@ -39,8 +39,7 @@ void InitializeSuppressions() {
   suppression_ctx = new (suppression_placeholder)
       SuppressionContext(kSuppressionTypes, ARRAY_SIZE(kSuppressionTypes));
   suppression_ctx->ParseFromFile(flags()->suppressions);
-  if (&__asan_default_suppressions)
-    suppression_ctx->Parse(__asan_default_suppressions());
+  suppression_ctx->Parse(__asan_default_suppressions());
 }
 
 bool IsInterceptorSuppressed(const char *interceptor_name) {
diff --git a/compiler-rt/lib/sanitizer_common/sancov_flags.cpp b/compiler-rt/lib/sanitizer_common/sancov_flags.cpp
index ed46e88acdfc6..43b4bcc76729a 100644
--- a/compiler-rt/lib/sanitizer_common/sancov_flags.cpp
+++ b/compiler-rt/lib/sanitizer_common/sancov_flags.cpp
@@ -37,10 +37,6 @@ static void RegisterSancovFlags(FlagParser *parser, SancovFlags *f) {
 #undef SANCOV_FLAG
 }
 
-static const char *MaybeCallSancovDefaultOptions() {
-  return (&__sancov_default_options) ? __sancov_default_options() : "";
-}
-
 void InitializeSancovFlags() {
   SancovFlags *f = sancov_flags();
   f->SetDefaults();
@@ -48,7 +44,7 @@ void InitializeSancovFlags() {
   FlagParser parser;
   RegisterSancovFlags(&parser, f);
 
-  parser.ParseString(MaybeCallSancovDefaultOptions());
+  parser.ParseString(__sancov_default_options());
   parser.ParseStringFromEnv("SANCOV_OPTIONS");
 
   ReportUnrecognizedFlags();



More information about the llvm-commits mailing list