[llvm-bugs] [Bug 40051] New: Incorrect optimisation of memswap routine results in loop crash

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Dec 17 05:54:20 PST 2018


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

            Bug ID: 40051
           Summary: Incorrect optimisation of memswap routine results in
                    loop crash
           Product: new-bugs
           Version: 6.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: aidan.chalk at stfc.ac.uk
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

Created attachment 21236
  --> https://bugs.llvm.org/attachment.cgi?id=21236&action=edit
tar containing the C source, plus .ll and .bc files from running through
bugpoint process

bash-4.2$ clang -v
clang version 6.0.0 (tags/RELEASE_600/final)
OS:
RedHat 7.4
Platform:
x86 (replicated on aarch64)

Attached .tar contains:
C code:
cell.h cell_split.c main.c memswap.h

To compile the (crashing code) you just need
clang -O1 cell_split.c main.c
-O2 and -O3 also result in a seg fault.

Code runs correctly with -O0 (program runs, no output is correct). Code also
works with gcc8 at all optimisation levels.

Adding a __sync_synchronize() statement to memswap.h line 60 and compiling with
-std=gnu99 causes the program to run correctly at all optimisation levels we
tested (-O3/-Ofast/-O2/-O1/-O0), however this fence should not be needed for
this example.


I ran bugpoint -llc-safe -O3 cell_split.ll main.ll on the .ll files created by
clang

It believes that 
opt bugpoint-reduced-instructions.bc -ee-instrument -tbaa -scoped-noalias
-simplifycfg -sroa -early-cse -lower-expect -forceattrs -tbaa -scoped-noalias
-inferattrs -ipsccp -called-value-propagation -globalopt -mem2reg -deadargelim
-instcombine -simplifycfg -globals-aa -prune-eh -inline -functionattrs -sroa
-early-cse-memssa -speculative-execution -jump-threading
-correlated-propagation -simplifycfg -instcombine -libcalls-shrinkwrap
-pgo-memop-opt -tailcallelim -simplifycfg -reassociate -loop-rotate -licm
-loop-unswitch -simplifycfg -instcombine -indvars -loop-idiom -loop-deletion
-loop-unroll -mldst-motion -gvn -memcpyopt -sccp -bdce -instcombine
-jump-threading -correlated-propagation -dse -licm -adce -simplifycfg
-instcombine -barrier -elim-avail-extern -rpo-functionattrs -globalopt
-globaldce -globals-aa -float2int -loop-rotate -loop-distribute -loop-vectorize
-loop-load-elim -instcombine -simplifycfg -instcombine -loop-unroll
-instcombine -licm -alignment-from-assumptions -strip-dead-prototypes
-globaldce -constmerge -loop-sink -instsimplify -div-rem-pairs -simplifycfg


should replicate the bug with reduced instructions

-- 
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/20181217/7e69a59a/attachment.html>


More information about the llvm-bugs mailing list