Revert "Revert r224736: "[Sanitizer] Make CommonFlags immutable after initialization.""
Fix test failures by introducing CommonFlags::CopyFrom() to make sure
compiler doesn't insert memcpy() calls into runtime code.
Original commit message:
Protect CommonFlags singleton by adding const qualifier to
common_flags() accessor. The only ways to modify the flags are
SetCommonFlagsDefaults(), ParseCommonFlagsFromString() and
OverrideCommonFlags() functions, which are only supposed to be
called during initialization.
llvm-svn: 225088
diff --git a/compiler-rt/lib/tsan/dd/dd_rtl.cc b/compiler-rt/lib/tsan/dd/dd_rtl.cc
index cc8e5a0..8728740 100644
--- a/compiler-rt/lib/tsan/dd/dd_rtl.cc
+++ b/compiler-rt/lib/tsan/dd/dd_rtl.cc
@@ -70,10 +70,14 @@
// Default values.
f->second_deadlock_stack = false;
- CommonFlags *cf = common_flags();
SetCommonFlagsDefaults();
- // Override some common flags defaults.
- cf->allow_addr2line = true;
+ {
+ // Override some common flags defaults.
+ CommonFlags cf;
+ cf.CopyFrom(*common_flags());
+ cf.allow_addr2line = true;
+ OverrideCommonFlags(cf);
+ }
// Override from command line.
ParseFlag(env, &f->second_deadlock_stack, "second_deadlock_stack", "");