<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 --- - Apple clang 4.2 based on llvm 3.2 produces a wrong "instruction requires:arm-mode"‏"
   href="http://llvm.org/bugs/show_bug.cgi?id=16315">16315</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Apple clang 4.2 based on llvm 3.2 produces a wrong "instruction requires:arm-mode"‏
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.2
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </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>Driver
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>mkravchik@hotmail.com
          </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>I've encountered this bug with Apple's clang based on llvm, but the bug happens
with the llvm's clang as well.
I've got an assembly file which used to compile with previous clang versions.
However with 4.2 I get the following error:

admin$
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-arch armv7 ./src/asm.s  -o asm.o

./src/asm.s:30:5: error: instruction requires a CPU feature not currently
enabled

    add r2, pc, r2


To reproduce the bug just compile a thumb assembly function with this
instruction.

According to ARM specification:

Use of PC and SP in Thumb instructions
In most of these instructions, you cannot use PC (R15) for Rd, or any operand.

The exceptions are:

you can use PC for Rn in 32-bit Thumb ADD and SUB instructions, with a constant
Operand2 value in the range 0-4095, and no S suffix. These instructions are
useful for generating PC-relative addresses. Bit[1] of the PC value reads as 0
in this case, so that the base address for the calculation is always
word-aligned.

you can use PC in 16-bit Thumb ADD{cond} Rd, Rd, Rm instructions, where both
registers cannot be PC.


I indeed specified that this line belongs to the Thumb function. But the clang
still produces this error.

When I compile this file directly with "as" it compiles correctly.

Please help!</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>