This is a re-do of D7931 with the following changes:
- the EpochTracker class is now conditional on LLVM_ENABLE_FAIL_FAST_ITERATORS and not NDEBUG.
- The most significant change: LLVM_ENABLE_FAIL_FAST_ITERATORS can be forced to be set or unset independent of NDEBUG. By default, cmake and autoconf set it (thus enabling fail-fast iterators) for with-asserts builds and unset it for without-asserts builds.
With these changes, projects that require ABI compatibility between
defined(NDEBUG) builds and !defined(NDEBUG) builds can get that by
clamping LLVM_ENABLE_FAIL_FAST_ITERATORS to on or off.
Minor changes from D7931
- HandleBase::getEpochAddress returns a void * to emphasise that the result is for comparison, not derefernecing.
- HandleBase::getEpochAddress was missing in the fail-fast-disabled version of HandleBase. This was not a problem earlier since the function is only called from asserts and when asserts were enabled, we'd always choose the fail-fast-enabled version of HandleBase. Since this is no longer the case (a with-asserts build may be using the fail-fast-disabled version of HandleBase), the missing method shows up as an obvious compiler error.
Original summary for D7931:
This patch is an attempt at making DenseMapIterators "fail-fast".
Fail-fast iterators that have been invalidated due to insertion into
the host DenseMap deterministically trip an assert (in debug mode)
on access, instead of non-deterministically hitting memory corruption
issues.