[llvm] r335788 - [X86] Make folding table checking threadsafe

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 27 14:30:33 PDT 2018


Thanks!

Does the similar code in X86EvexToVex.cpp also need this?

Is what you did here better or worse the std::atomic used in ASSERT_SORTED
in X86FloatingPoint.cpp?

~Craig


On Wed, Jun 27, 2018 at 2:06 PM Benjamin Kramer via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> 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
>  }
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180627/8333d744/attachment.html>


More information about the llvm-commits mailing list