[llvm-bugs] [Bug 48514] New: wrong code with "-tbaa -globalopt -mem2reg -instcombine -inline -early-cse-memssa -licm"
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Dec 15 04:45:15 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=48514
Bug ID: 48514
Summary: wrong code with "-tbaa -globalopt -mem2reg
-instcombine -inline -early-cse-memssa -licm"
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 24282
--> https://bugs.llvm.org/attachment.cgi?id=24282&action=edit
IR that is passed to opt
*******************************************************************************
OS and Platform:
CentOS Linux release 7.8.2003 (Core), x86_64 GNU/Linux
*******************************************************************************
Program:
int printf(const char *, ...);
union a {
long b;
short c;
int d;
} e, f;
unsigned *g = &e.d;
union a h() {
for (;;) {
long *i = &e.b;
*i = 0;
for (; 4;) {
--*g;
return f;
}
}
}
int main() {
h();
printf("%d\n", e.c);
}
*******************************************************************************
clang version:
$ clang -v
clang version 12.0.0 (/home/suocy/src/llvm-dev/llvm-project/llvm/tools/clang
c4d2d4337d50bed3cafd564daece1a197005b22b)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/suocy/bin/llvm-dev/bin
Found candidate GCC installation:
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5
Selected GCC installation:
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
*******************************************************************************
Command Lines:
$ clang -O3 -mllvm -disable-llvm-optzns -c -emit-llvm a.c -o a.bc
a.c:7:11: warning: initializing 'unsigned int *' with an expression of type
'int *' converts between pointers to integer types with different sign
[-Wpointer-sign]
unsigned *g = &e.d;
^ ~~~~
1 warning generated.
$ opt -tbaa -globalopt -mem2reg -instcombine -inline -early-cse-memssa -licm
a.bc -o a.opt1.bc
$ opt a.bc -o a.opt2.bc
$ clang a.opt1.bc -o a1.o
$ clang a.opt2.bc -o a2.o
$ ./a1.o
0
$ ./a2.o
-1
--
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/20201215/693b6751/attachment.html>
More information about the llvm-bugs
mailing list