Testcase: #include <stdlib.h> void t() { throw 0; } void (*tt)() = t; void f(int*__restrict a, int x, bool y) { for (int i = 0; i < x; ++i) { *a += 1; if (y) tt(); } } void (*ff)(int*__restrict,int,bool) = f; int main() { int a = 0; try { ff(&a, 10, true); } catch (...) { if (a != 1) abort(); } } Runs to completion with clang -O0, aborts with clang -O2. The problem is incomplete safety checks in LICM. (Artificial testcase.)
http://reviews.llvm.org/D20944 .
r271858.