llvm / llvm/llvm-project

[IndVars] Wrong code at -O1

Open
#221,524 7 comments 0 reactions 1 assignee Claimed by @antoniofrighetto View on GitHub
confirmed generated by fuzzer loopoptim miscompilation
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Reproducer: https://godbolt.org/z/ajhGq6YGW
Reduced case:
```c
#include
struct s0
{
uint16_t f1[77];
};
struct
{
struct s0 f2[1];
} volatile g1;
uint32_t g11, g25;
_Bool g13, f2_c17;
_Bool f3_sf9;
void f3(uint64_t a3)
{
uint32_t v18;
lbl_entry:
if (g13 || g25 != 1130031779)
{
g13 = __builtin_add_overflow(a3, a3, &a3);
v18 = g11;
}
else
g1.f2[v18 / 3692536403].f1[a3];
if (f3_sf9) goto lbl_entry;
}
int main()
{
lbl_sw8:
f3(10297575660885481619u);
f2_c17 = f2_c17 ^ 1;
g25 = 1130031779;
if (f2_c17) goto lbl_sw8;
}
```

This case triggers SIGSEGV at -O1, and terminates normally at -O0.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.