<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Incorrect optimisation of memswap routine results in loop crash"
href="https://bugs.llvm.org/show_bug.cgi?id=40051">40051</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Incorrect optimisation of memswap routine results in loop crash
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>6.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>aidan.chalk@stfc.ac.uk
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=21236" name="attach_21236" title="tar containing the C source, plus .ll and .bc files from running through bugpoint process">attachment 21236</a> <a href="attachment.cgi?id=21236&action=edit" title="tar containing the C source, plus .ll and .bc files from running through bugpoint process">[details]</a></span>
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</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>