<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - clang generates illegal ARM STR opcode with FlexOffset"
   href="http://llvm.org/bugs/show_bug.cgi?id=20323">20323</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang generates illegal ARM STR opcode with FlexOffset
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.4
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>LLVM Codegen
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>max@duempel.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=12776" name="attach_12776" title="Demo program">attachment 12776</a> <a href="attachment.cgi?id=12776&action=edit" title="Demo program">[details]</a></span>
Demo program

Compile the attached program on an ARM (e.g. Raspberry Pi, Cubieboard) with:
clang++ -std=c++11 -O2 -S str_flexoffset.cpp

The resulting assembly file contains the following opcode:

        str     r2, [r2], #4

Some CPUs crash with SIGILL (e.g. Qualcomm QSD8250, Allwinner A20), while
others ignore the problem (e.g. Qualcomm MSM7200A, Allwinner A10, Exynos 4210).

Documentation on STR:
<a href="http://infocenter.arm.com/help/topic/com.arm.doc.dui0068b/Bcfihdhj.html#Chdjhhhe">http://infocenter.arm.com/help/topic/com.arm.doc.dui0068b/Bcfihdhj.html#Chdjhhhe</a>

"Rn must not be the same as Rd, if the instruction:
    is pre-indexed with writeback (the ! suffix);
    is post-indexed;
    uses the T suffix;"

Here, Rn and Rd are the same, and the ", #4" is a post-indexed FlexOffset. This
combination is illegal.

I could observe this problem with clang 3.5 (Debian 1:3.5~svn211669-1), clang
3.4 (Android NDK r9d) and clang 3.0 (Debian 1:3.0-6.2).

Link to the original bug report: <a href="http://bugs.xcsoar.org/ticket/3356">http://bugs.xcsoar.org/ticket/3356</a></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>