Testcase: #include <stdlib.h> void f() { exit(0); } void (*ff)() = f; void g(int* restrict a) { for (int i = 0; i < 1000; ++i) { ff(); *a += 1; } } void (*gg)(int* restrict) = g; int main() { gg(0); } Works with gcc and clang -O0; crashes with clang -O2. I think LICM is relying too much on "MayThrow" to conclude that function calls will return normally. Testcase is artificial.
http://reviews.llvm.org/rL272489 .