r337748 made it so that DebugCounters are always incremented in asserting builds, so that we can better track how many times certain passes are run. This change broke some multithreaded tsan builds (D50080), since we increment these global counters in an unsynchronized manner.
We only need these counter values if we're either using a DebugCounter to limit a pass, or if we plan to print them out (D50031). Having an enable bit to track that seems like the best way forward.
I don't have a test, since the global state at play here makes unittesting pretty awkward, and we have some existing test coverage here. Happy to try to make something if people want that, though.
Whatever the fix here ends up being, I intend to try to get it into the 7.0 branch.