[llvm-bugs] [Bug 40496] New: a pass error, this pass never consider data overflow

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jan 28 07:45:44 PST 2019


            Bug ID: 40496
           Summary: a pass error, this pass never consider data overflow
           Product: clang
           Version: 7.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: witstorm at 163.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

Created attachment 21395
  --> https://bugs.llvm.org/attachment.cgi?id=21395&action=edit
source code for error proof

Here have a simple program in the attachment.
typedef unsigned char X;
//typedef char X;
X Fb(X x, X y){return x + y;}
int main()
  auto int ai0,ai1;
  ai0 = 0;
  ai1 = 2147483647;
  ai0 = ai1 + Fb(63, 64);
  printf("%d\n",ai0 == -2147483522);
If we use clang to generate .ll file by -O3, we will get wrong .ll file.
The compile command like that: clang a.c -O3 -emit-llvm -S -o aa.ll
we find the pass where did this optimize. There problem is the pass never
consider data overflow for icmp constant fold. And I find the same bug in other
passes, if you need it, just contact me by email(witstorm at 163.com). 
Run the code, it should print 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/20190128/365c97c7/attachment.html>

More information about the llvm-bugs mailing list