OSDN Git Service

[X86] Make folding table checking threadsafe
authorBenjamin Kramer <benny.kra@googlemail.com>
Wed, 27 Jun 2018 21:01:53 +0000 (21:01 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Wed, 27 Jun 2018 21:01:53 +0000 (21:01 +0000)
This is a benign race, but tsan likes to complain about it. Just make it
happy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335788 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86InstrInfo.cpp

index a5c6b19..7096e82 100644 (file)
@@ -5413,8 +5413,7 @@ X86InstrInfo::X86InstrInfo(X86Subtarget &STI)
 
 #ifndef NDEBUG
   // Make sure the tables are sorted.
-  static bool FoldTablesChecked = false;
-  if (!FoldTablesChecked) {
+  static bool LLVM_ATTRIBUTE_UNUSED FoldTablesChecked = [] {
     assert(std::is_sorted(std::begin(MemoryFoldTable2Addr),
                           std::end(MemoryFoldTable2Addr)) &&
            std::adjacent_find(std::begin(MemoryFoldTable2Addr),
@@ -5451,8 +5450,8 @@ X86InstrInfo::X86InstrInfo(X86Subtarget &STI)
                               std::end(MemoryFoldTable4)) ==
            std::end(MemoryFoldTable4) &&
            "MemoryFoldTable4 is not sorted and unique!");
-    FoldTablesChecked = true;
-  }
+    return true;
+  }();
 #endif
 }