opt-bisect
An LLVM flag that runs the first N optimization steps and skips the rest, letting you binary-search for exactly which step breaks a program.
When a program works at -O0 and crashes at -O2, there are hundreds of pass invocations to suspect. -opt-bisect-limit=N numbers every run of a pass over a function or loop and allows only the first N; from Clang you pass it through -mllvm. Halve N until the bug disappears, and the last step allowed is the culprit, printed by name along with the function it touched. Same idea as git bisect, applied to the optimization pipeline instead of history.
That said, the answer is more often undefined behaviour in the program than a compiler bug; the pass it fingers is merely the first one to exploit it. GCC has a similar knob in its debug counters, -fdbg-cnt.