[compiler-rt] r214831 - [Sanitizer] Turn SuppressionContext::Init() into InitIfNecessary().
Alexey Samsonov
vonosmas at gmail.com
Mon Aug 4 17:43:23 PDT 2014
Author: samsonov
Date: Mon Aug 4 19:43:23 2014
New Revision: 214831
URL: http://llvm.org/viewvc/llvm-project?rev=214831&view=rev
Log:
[Sanitizer] Turn SuppressionContext::Init() into InitIfNecessary().
Suppression context might be used in multiple sanitizers working
simultaneously (e.g. LSan and UBSan) and not knowing about each other.
Modified:
compiler-rt/trunk/lib/lsan/lsan_common.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_suppressions.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_suppressions.h
compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc
Modified: compiler-rt/trunk/lib/lsan/lsan_common.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan_common.cc?rev=214831&r1=214830&r2=214831&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lsan_common.cc (original)
+++ compiler-rt/trunk/lib/lsan/lsan_common.cc Mon Aug 4 19:43:23 2014
@@ -83,10 +83,14 @@ static void InitializeFlags() {
if (flags()->log_threads) Report(__VA_ARGS__); \
} while (0);
+static bool suppressions_inited = false;
+
void InitializeSuppressions() {
- SuppressionContext::Init();
+ CHECK(!suppressions_inited);
+ SuppressionContext::InitIfNecessary();
if (&__lsan_default_suppressions)
SuppressionContext::Get()->Parse(__lsan_default_suppressions());
+ suppressions_inited = true;
}
struct RootRegion {
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_suppressions.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_suppressions.cc?rev=214831&r1=214830&r2=214831&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_suppressions.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_suppressions.cc Mon Aug 4 19:43:23 2014
@@ -75,8 +75,9 @@ SuppressionContext *SuppressionContext::
return suppression_ctx;
}
-void SuppressionContext::Init() {
- CHECK(!suppression_ctx);
+void SuppressionContext::InitIfNecessary() {
+ if (suppression_ctx)
+ return;
suppression_ctx = new(placeholder) SuppressionContext;
if (common_flags()->suppressions[0] == '\0')
return;
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_suppressions.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_suppressions.h?rev=214831&r1=214830&r2=214831&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_suppressions.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_suppressions.h Mon Aug 4 19:43:23 2014
@@ -45,9 +45,10 @@ class SuppressionContext {
const Suppression *SuppressionAt(uptr i) const;
void GetMatched(InternalMmapVector<Suppression *> *matched);
- // Create a SuppressionContext singleton. Not thread safe. Must be called
- // early during initialization.
- static void Init();
+ // Create a SuppressionContext singleton if it hasn't been created earlier.
+ // Not thread safe. Must be called early during initialization (but after
+ // runtime flags are parsed).
+ static void InitIfNecessary();
// Returns a SuppressionContext singleton.
static SuppressionContext *Get();
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc?rev=214831&r1=214830&r2=214831&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc Mon Aug 4 19:43:23 2014
@@ -41,12 +41,16 @@ extern "C" const char *WEAK __tsan_defau
namespace __tsan {
+static bool suppressions_inited = false;
+
void InitializeSuppressions() {
- SuppressionContext::Init();
+ CHECK(!suppressions_inited);
+ SuppressionContext::InitIfNecessary();
#ifndef TSAN_GO
SuppressionContext::Get()->Parse(__tsan_default_suppressions());
SuppressionContext::Get()->Parse(std_suppressions);
#endif
+ suppressions_inited = true;
}
SuppressionType conv(ReportType typ) {
More information about the llvm-commits
mailing list