[compiler-rt] [compiler-rt] Remove redundant checks. (PR #95753)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 17 01:36:13 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: Dmitriy Chestnykh (chestnykh)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/95753.diff
2 Files Affected:
- (modified) compiler-rt/lib/asan/asan_suppressions.cpp (+1-2)
- (modified) compiler-rt/lib/sanitizer_common/sancov_flags.cpp (+1-5)
``````````diff
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();
``````````
</details>
https://github.com/llvm/llvm-project/pull/95753
More information about the llvm-commits
mailing list