<html>
    <head>
      <base href="https://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 --- - disagreement with GCC about ABI of libgcc functions on hard-float ARM"
   href="https://llvm.org/bugs/show_bug.cgi?id=27455">27455</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>disagreement with GCC about ABI of libgcc functions on hard-float ARM
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>brian@peloton-tech.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>anton@korobeynikov.info, compnerd@compnerd.org, jonathan@codesourcery.com, kristof.beyls@arm.com, llvm-bugs@lists.llvm.org, tzuhsiang.chien@gmail.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=16246" name="attach_16246" title="A simple program which demonstrates the affects">attachment 16246</a> <a href="attachment.cgi?id=16246&action=edit" title="A simple program which demonstrates the affects">[details]</a></span>
A simple program which demonstrates the affects

Clang and GCC disagree about the calling convention for the helper functions in
libgcc/compiler-rt on ARM with hardware floating point. Clang passes the
floating point arguments in integer registers (like with -mfloat-abi=soft), but
GCC calls them like other functions with the hard-float ABI. The only reference
to this I can find online is an LLVM development mailing list post [1]
discussing why Clang switched to always using soft-float. At least one of the
Clang developers thought GCC did this too, but it doesn't seem to currently.
Complex arithmetic is implemented with these functions even when hardware
floating point is supported, which means complex arithmetic is pretty
completely broken on platforms like this when using libgcc.

[1] <a href="http://lists.llvm.org/pipermail/llvm-dev/2014-October/077898.html">http://lists.llvm.org/pipermail/llvm-dev/2014-October/077898.html</a>

I found the code in clang's lib/CodeGen/TargetInfo.cpp which sets BuiltinCC to
CallingConv::ARM_AAPCS and the __attribute__((pcs("aapcs"))) in compiler-rt's
lib/builtins/int_lib.h which compiles the relevant functions that way. I can't
find any evidence of GCC doing either of those.

In all three copies of libgcc.a I've disassembled (Debian Jessie armhf and both
of the ones from gcc-linaro-4.9-2015.05-x86_64_arm-linux-gnueabihf) __divdc3
(for example) definitely uses the hard-float ABI. In
clang+llvm-3.8.0-armv7a-linux-gnueabihf/lib/clang/3.8.0/lib/linux/libclang_rt.builtins-armhf.a
(downloaded from llvm.org), __divdc3 is definitely using the soft-float ABI.

Attached is a simple program which demonstrates the effects. 
I've tried with Clang 3.7.1 I cross-compiled for armhf myself and 3.8.0
binaries downloaded from llvm.org.
$ gcc -lm test_complex.c -O3 && ./a.out
works
$ clang -lm test_complex.c -O3 && ./a.out
broken

On 4/21/16 2:36 PM, Renato Golin via cfe-dev wrote:
<span class="quote">> I checked with the GCC folks, and the behaviour is:

>  * arm-linux-gnueabi has *only* soft-float
>  * arm-linux-gnueagihf has *only* hard float
>  * arm-none-eabi has *all* variations (above) with the default being soft-float</span ></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>