LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 27857 - licm miscompile with noalias and call which exits program
Summary: licm miscompile with noalias and call which exits program
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Loop Optimizer (show other bugs)
Version: trunk
Hardware: PC Windows NT
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-24 13:05 PDT by Eli Friedman
Modified: 2016-06-11 17:20 PDT (History)
2 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eli Friedman 2016-05-24 13:05:57 PDT
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.
Comment 1 Eli Friedman 2016-06-11 17:20:52 PDT
http://reviews.llvm.org/rL272489 .