[llvm-bugs] [Bug 48333] New: wrong code with "-inline -early-cse-memssa -simplifycfg -instcombine -loop-unroll"

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Nov 29 23:53:28 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=48333

            Bug ID: 48333
           Summary: wrong code with "-inline -early-cse-memssa
                    -simplifycfg -instcombine -loop-unroll"
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: suochenyao at 163.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

Created attachment 24220
  --> https://bugs.llvm.org/attachment.cgi?id=24220&action=edit
bc file

*******************************************************************************
OS and Platform:
CentOS Linux release 7.8.2003 (Core), x86_64 GNU/Linux
*******************************************************************************
Program:
$ cat a.c
int printf(const char *, ...);
int a=0, c=0, d=0;
int b[10];
void e() {
  int *f = &d;
  d = -19;
  for (; d > 3; ++d)
    ;
  *f = (f == f) >> *f;
}
int main() {
  e();
  c = b[d];
  printf("%X\n", a);
}
*******************************************************************************
clang version:
$ clang --version
clang version 12.0.0 (/home/suocy/src/llvm-dev/llvm-project/llvm/tools/clang
f15b7869e5afbd6c24ef440b0b62593e80fbd24f)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/suocy/bin/llvm-dev/bin
*******************************************************************************
Command Lines:
$ clang -c -emit-llvm -O3 -mllvm -disable-llvm-optzns a.c -o a.bc
a.c:9:11: warning: self-comparison always evaluates to true
[-Wtautological-compare]
  *f = (f == f) >> *f;
          ^
1 warning generated.
$ opt a.bc -o a.opt1.bc
$ clang a.opt1.bc -o a1.o
$ opt -inline -early-cse-memssa -simplifycfg -instcombine -loop-unroll a.bc -o
a.opt2.bc
$ clang a.opt2.bc -o a2.o
$ ./a1.o
0
$ ./a2.o
Segmentation fault

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201130/2ce797b1/attachment.html>


More information about the llvm-bugs mailing list