[llvm] r335788 - [X86] Make folding table checking threadsafe
Benjamin Kramer via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 27 14:01:53 PDT 2018
Author: d0k
Date: Wed Jun 27 14:01:53 2018
New Revision: 335788
URL: http://llvm.org/viewvc/llvm-project?rev=335788&view=rev
Log:
[X86] Make folding table checking threadsafe
This is a benign race, but tsan likes to complain about it. Just make it
happy.
Modified:
llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=335788&r1=335787&r2=335788&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Wed Jun 27 14:01:53 2018
@@ -5413,8 +5413,7 @@ X86InstrInfo::X86InstrInfo(X86Subtarget
#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
std::end(MemoryFoldTable4)) ==
std::end(MemoryFoldTable4) &&
"MemoryFoldTable4 is not sorted and unique!");
- FoldTablesChecked = true;
- }
+ return true;
+ }();
#endif
}
More information about the llvm-commits
mailing list