<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 --- - ARM MC assembler allows backward branching on CBNZ instruction."
   href="http://llvm.org/bugs/show_bug.cgi?id=20359">20359</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>ARM MC assembler allows backward branching on CBNZ instruction.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>sgundapa@codeaurora.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=12791" name="attach_12791" title="Test case to demonstrate the issue">attachment 12791</a> <a href="attachment.cgi?id=12791&action=edit" title="Test case to demonstrate the issue">[details]</a></span>
Test case to demonstrate the issue

I have attached an arm assembly file which can demonstrate the issue.
(The test case is an excerpt from compiler-rt ARM builtins library)

$ clang  -mcpu=cortex-a9 -c /tmp/temp.s -no-integrated-as -o /tmp/temp.o
/tmp/temp.s: Assembler messages:
/tmp/temp.s:13: Error: branch out of range
clang-3.5: error: assembler command failed with exit code 1 (use -v to see
invocation)

$ clang  -mcpu=cortex-a9 -c /tmp/temp.s -integrated-as -o /tmp/temp.o
The integrated-as compiles the file with out an issue and generates bad
assembly

$ arm-none-linux-gnueabi-objdump -S /tmp/temp.o
/tmp/temp.o:     file format elf32-littlearm
Disassembly of section .text:
00000000 <__sync_fetch_and_add_8>:
   0:    b570          push    {r4, r5, r6, lr}
   2:    f3bf 8f5f     dmb    sy
   6:    4684          mov    ip, r0
   8:    e8dc 017f     ldrexd    r0, r1, [ip]
   c:    1884          adds    r4, r0, r2
   e:    eb41 0503     adc.w    r5, r1, r3
  12:    e8cc 4576     strexd    r6, r4, r5, [ip]
  16:    bbbe          cbnz    r6, 88 <__sync_fetch_and_add_8+0x88>
  18:    f3bf 8f5f     dmb    sy
  1c:    bd70          pop    {r4, r5, r6, pc}


There is no address corresponding to 88 <__sync_fetch_and_add_8+0x88>.

The ARM manual on CBNZ says backward branching is not possible.
Refer to
<a href="http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0489c/Cjaghefc.html">http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0489c/Cjaghefc.html</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>