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 27952 - licm miscompile with restrict and throw
Summary: licm miscompile with restrict and throw
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-31 15:46 PDT by Eli Friedman
Modified: 2016-06-05 17:15 PDT (History)
3 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-31 15:46:04 PDT
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.)
Comment 1 Eli Friedman 2016-06-02 22:50:01 PDT
http://reviews.llvm.org/D20944 .
Comment 2 Eli Friedman 2016-06-05 17:15:46 PDT
r271858.