[llvm-bugs] [Bug 28443] New: integer truncation error in areStridedAccessesIndependent

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jul 6 22:18:30 PDT 2016


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

            Bug ID: 28443
           Summary: integer truncation error in
                    areStridedAccessesIndependent
           Product: new-bugs
           Version: 3.8
          Hardware: PC
                OS: FreeBSD
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: cperciva at freebsd.org
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 16701
  --> https://llvm.org/bugs/attachment.cgi?id=16701&action=edit
Test case; crashes clang38 -O2

The attached reduced test case crashes clang38 -c -O2 on my FreeBSD/amd64
system:

Assertion failed: (Distance > 0 && "The distance must be non-zero"), function
areStridedAccessesIndependent, file
/wrkdirs/usr/ports/devel/llvm38/work/llvm-3.8.0.src/lib/Analysis/LoopAccessAnalysis.cpp,
line 1004.

This is because the function areStridedAccessIndependent takes "unsigned"
values

static bool areStridedAccessesIndependent(unsigned Distance, unsigned Stride,
                                          unsigned TypeByteSize)

where it should be taking target size_t values: I am compiling for a 64-bit
platform, and the distance between memory accesses is 2^32 bytes, but the
"unsigned" type is a 32-bit integer so 2^32 gets truncated to 0.

In addition to causing a crash when the distance between memory accesses is a
multiple of 2^32 bytes, this bug could theoretically cause incorrect code
generation, e.g., if the distance is 2^32+2 bytes and the stride length is
2^31+1; using 32-bit integers it appears that the distance is not a multiple of
the stride length, and invalid optimizations may occur.

-- 
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/20160707/59fef038/attachment.html>


More information about the llvm-bugs mailing list