TableGen crash when building LLVM with EXPENSIVE_CHECKS enabled

I'm trying to run checks with EXPENSIVE_CHECKS enabled, but it crashes when
generating some intrinsics file with TableGen.

cd /home/luke/Source/llvm-project/build && /home/luke/Source/llvm-
project/build/bin/llvm-tblgen -gen-intrinsic-impl -I /home/luke/Source/llvm-
project/llvm/include/llvm/IR -I /home/luke/Source/llvm-project/llvm/include
/home/luke/Source/llvm-project/llvm/include/llvm/IR/ -o
include/llvm/IR/ -d include/llvm/IR/
Error: attempt to self move assign.

Objects involved in the operation:
    sequence "this" @ 0x0x7fe3b3070468 {

The command I've been using to configure it is

cmake ../llvm -G Ninja \

Removing the -DLLVM_ENABLE_EXPENSIVE_CHECKS=On allows it to build. Is there
something wrong with the version on libstdc++ on my system? (Debian testing)
This was happening on revision 5857bf5d1e5a5ffe5ae51a38514ee55495c0cc69

I briefly dug into this and I can reproduce it, the issue appears to
be the implementation of std::shuffle (which is called by llvm::sort
with expensive checks).

Sounds like you should file a bug against libstdc++.


This looks like to me. I added a workaround ( to our fork but never got around to submitting a review.

If adding a copy of the libc++ implementation as llvm::shuffle seems like a valid approach I’ll upload the patch to phabricator.


FYI I just hit this, but found that adding -DLLVM_OPTIMIZED_TABLEGEN=ON when I configured llvm fixed/hid the issue. Not sure why, but I found this flag when examining how one of the expensive-checks bots was configured.