Since upgrading a machine from Ubuntu 20.04 to 22.04 I have noticed that a bunch of tests fail in an LLVM_ENABLE_EXPENSIVE_CHECKS build:
Failed Tests (39):
LLVM :: CodeGen/X86/code_placement_ext_tsp.ll
LLVM :: CodeGen/X86/code_placement_ext_tsp_large.ll
LLVM :: DebugInfo/assignment-tracking/X86/DSE.ll
LLVM :: DebugInfo/assignment-tracking/X86/dbg-phi-produces-undef.ll
LLVM :: DebugInfo/assignment-tracking/X86/diamond-1.ll
LLVM :: DebugInfo/assignment-tracking/X86/diamond-2.ll
LLVM :: DebugInfo/assignment-tracking/X86/diamond-3.ll
LLVM :: DebugInfo/assignment-tracking/X86/loop-hoist.ll
LLVM :: DebugInfo/assignment-tracking/X86/loop-sink.ll
LLVM :: DebugInfo/assignment-tracking/X86/loop-unroll.ll
LLVM :: DebugInfo/assignment-tracking/X86/lower-offset-expression.ll
LLVM :: DebugInfo/assignment-tracking/X86/lower-to-value.ll
LLVM :: DebugInfo/assignment-tracking/X86/mem-loc-frag-fill-cfg.ll
LLVM :: DebugInfo/assignment-tracking/X86/mem-loc-frag-fill.ll
LLVM :: DebugInfo/assignment-tracking/X86/nested-loop-frags.ll
LLVM :: DebugInfo/assignment-tracking/X86/nested-loop-sroa.ll
LLVM :: DebugInfo/assignment-tracking/X86/nested-loop.ll
LLVM :: DebugInfo/assignment-tracking/X86/no-redundant-def-after-alloca.ll
LLVM :: DebugInfo/assignment-tracking/X86/order-of-defs.ll
LLVM :: DebugInfo/assignment-tracking/X86/remove-redundant-defs-to-prevent-reordering.ll
LLVM :: DebugInfo/assignment-tracking/X86/remove-undef-fragment.ll
LLVM :: DebugInfo/assignment-tracking/X86/sdag-dangling-dbgassign.ll
LLVM :: DebugInfo/assignment-tracking/X86/sdag-ir-salvage-assign.ll
LLVM :: DebugInfo/assignment-tracking/X86/sdag-transfer-dbgassign.ll
LLVM :: DebugInfo/assignment-tracking/X86/single-memory-location-2.ll
LLVM :: DebugInfo/assignment-tracking/X86/single-memory-location.ll
LLVM :: DebugInfo/assignment-tracking/X86/split-alloca.ll
LLVM :: DebugInfo/assignment-tracking/X86/untagged-store-frag.ll
LLVM :: DebugInfo/assignment-tracking/X86/use-known-value-at-early-mem-def-2.ll
LLVM :: DebugInfo/assignment-tracking/X86/use-known-value-at-early-mem-def.ll
LLVM :: Transforms/Inline/nested-inline.ll
LLVM :: Transforms/LICM/loopsink.ll
LLVM :: Transforms/SampleProfile/csspgo-import-list.ll
LLVM-Unit :: ADT/./ADTTests/10/44
LLVM-Unit :: ADT/./ADTTests/18/44
LLVM-Unit :: ADT/./ADTTests/2/44
LLVM-Unit :: ADT/./ADTTests/26/44
LLVM-Unit :: ADT/./ADTTests/34/44
LLVM-Unit :: ADT/./ADTTests/42/44
The build is using clang-14 with libstdc+±12 as the host toolchain.
The failures I have investigated all look something like this:
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/debug/safe_iterator.h:472:
In function:
bool gnu_debug::operator==(const gnu_debug::_Safe_iterator::_Self &,
const gnu_debug::_Safe_iterator::_Self &)
Error: attempt to compare a singular iterator to a
dereferenceable (start-of-sequence) iterator.
Objects involved in the operation:
iterator "lhs" @ 0x7fffffffe420 {
state = singular;
}
iterator "rhs" @ 0x7fffffffe480 {
state = dereferenceable (start-of-sequence);
references sequence @ 0x7fffffffe510
}
LLVM_ENABLE_EXPENSIVE_CHECKS usually #defines _GLIBCXX_DEBUG, but If I forcibly undefine this then the failures go away.
Is this a known problem? Is it a bug in LLVM or a bug in libstdc++'s debug checking?