[LLVMdev] [Compiler-RT] [ARM] Where __aeabi_[il]div0 builtins should be implemented?

Saleem Abdulrasool compnerd at compnerd.org
Tue Sep 9 22:39:50 PDT 2014


On Tue, Sep 9, 2014 at 1:37 AM, Renato Golin <renato.golin at linaro.org>
wrote:

> On 9 September 2014 02:18, Saleem Abdulrasool <compnerd at compnerd.org>
> wrote:
> > The current implementations actually return 0.  Can you point out where
> that
> > doesn't hold please?
>
> With the current implementation...
>
> int foo(int a) {
>   return __aeabi_idiv0(a);
> }
>
> returns 'a', while:
>
> int bar(int a) {
>   return __aeabi_idiv(a, 0);
> }
>
> returns zero.
>
>
> > Quoting the RTABI:
> >
> >    int __aeabi_idiv0(int return_value);
> >    long long __aeabi_ldiv0(long long return_value);
> >
> > The *div0 functions:
> >
> > 􏰁  Return the value passed to them as a parameter.
> >
> > Is my copy out of date?
>
> As I said before, all three behaviours are allowed by the RTABI
> (exception, constant, parameter), but we now have two different
> behaviours in compiler-rt. This is a regression.
>
> We must make it consistent to what there was there before (return
> zero). If you *really* want to make it return the parameter or signal,
> we should discuss this properly, on another thread, but right now,
> division by zero in compiler-rt has to return zero.


Oh!  I think I see what the confusion is all about.  __aeabi_[il]div0 are
*NOT* division routines.  They are handlers for the error case of division
by zero.  They do not perform a division by zero, they effectively are
meant to trap the fact that a division by zero has occurred.


>
> --renato
>

-- 
Saleem Abdulrasool
compnerd (at) compnerd (dot) org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140909/abf9b13e/attachment.html>


More information about the llvm-dev mailing list