<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Wed, Jun 27, 2018 at 11:30 PM Craig Topper <<a href="mailto:craig.topper@gmail.com">craig.topper@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Thanks!</div><div><br></div>Does the similar code in X86EvexToVex.cpp also need this?</div></blockquote><div><br></div><div>Yes. I think it didn't show up in my testing because the tests don't use AVX512 (yet)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Is what you did here better or worse the std::atomic used in ASSERT_SORTED in X86FloatingPoint.cpp?<br clear="all"></div></div></blockquote><div><br></div><div>The main difference is that ASSERT_SORTED might run the check multiple times while the thread-safe static idiom only runs them once. Doesn't make a difference in practice though. Thread-safe static is a bit more heavyweight in cases where performance matters.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div dir="ltr" class="m_-5958834870430883359gmail_signature" data-smartmail="gmail_signature">~Craig</div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Jun 27, 2018 at 2:06 PM Benjamin Kramer via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: d0k<br>
Date: Wed Jun 27 14:01:53 2018<br>
New Revision: 335788<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=335788&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=335788&view=rev</a><br>
Log:<br>
[X86] Make folding table checking threadsafe<br>
<br>
This is a benign race, but tsan likes to complain about it. Just make it<br>
happy.<br>
<br>
Modified:<br>
llvm/trunk/lib/Target/X86/X86InstrInfo.cpp<br>
<br>
Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=335788&r1=335787&r2=335788&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=335788&r1=335787&r2=335788&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original)<br>
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Wed Jun 27 14:01:53 2018<br>
@@ -5413,8 +5413,7 @@ X86InstrInfo::X86InstrInfo(X86Subtarget<br>
<br>
#ifndef NDEBUG<br>
// Make sure the tables are sorted.<br>
- static bool FoldTablesChecked = false;<br>
- if (!FoldTablesChecked) {<br>
+ static bool LLVM_ATTRIBUTE_UNUSED FoldTablesChecked = [] {<br>
assert(std::is_sorted(std::begin(MemoryFoldTable2Addr),<br>
std::end(MemoryFoldTable2Addr)) &&<br>
std::adjacent_find(std::begin(MemoryFoldTable2Addr),<br>
@@ -5451,8 +5450,8 @@ X86InstrInfo::X86InstrInfo(X86Subtarget<br>
std::end(MemoryFoldTable4)) ==<br>
std::end(MemoryFoldTable4) &&<br>
"MemoryFoldTable4 is not sorted and unique!");<br>
- FoldTablesChecked = true;<br>
- }<br>
+ return true;<br>
+ }();<br>
#endif<br>
}<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>
</blockquote></div></div>