<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 doesn't produce ARM EABI-compliant modulo runtime function"
   href="http://llvm.org/bugs/show_bug.cgi?id=16387">16387</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang doesn't produce ARM EABI-compliant modulo runtime function
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>All
          </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>Backend: ARM
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>kristof.beyls@arm.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>For the following program:
$ cat divmod.c
int f(int a, int b) {
    int d = a/b;
    int m = a%b;
    int c = b%a;
    return d+m+c;
}

compiled with the following command line:
clang -O3 -target armv7a-none-none-eabi -mcpu=cortex-a8 divmod.c -S

clang produces code that is not EABI compliant:
f:
        push    {r4, r5, r6, r11, lr}
        add     r11, sp, #12
        sub     sp, sp, #4
        mov     r5, r1
        mov     r4, r0
        bl      __aeabi_idiv
        mov     r6, r0
        mov     r0, r4
        mov     r1, r5
        bl      __modsi3
        add     r6, r0, r6
        mov     r0, r5
        mov     r1, r4
        bl      __modsi3
        add     r0, r6, r0
        sub     sp, r11, #12
        pop     {r4, r5, r6, r11, pc}


The problem is the calls to __modsi3. These are not compliant with the EABI.
Instead, clang should produce calls to __aeabi_idivmod or __aeabi_uidivmod for
modulo operations when producing EABI-compliant code.</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>