[cfe-dev] Floating-point traps on x86-64

Cameron McInally via cfe-dev cfe-dev at lists.llvm.org
Thu Mar 7 12:02:58 PST 2019


Hey John,

This is something we're currently working on. See:

https://llvm.org/docs/LangRef.html#constrained-floating-point-intrinsics

There's still a lot to be done though. Short of this work, I don't think
you'll find guarantees of trap-safety in LLVM.

Hope that helps,
Cameron

On Thu, Mar 7, 2019 at 7:38 AM Dallman, John via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> I produce a mathematical modelling library on several platforms, including
> iOS, macOS and Android, all of which use Clang. On x86-based platforms, the
> hardware can generate floating-point traps. I prefer to run testing with
> traps for Invalid Operation, Divide-by-Zero and Overflow active, since that
> finds me problem sites more quickly than working backwards from “this test
> case failed.”
>
>
>
> However, I had a problem with Apple Clang 8.x, which I believe was LLVM
> 3.9, targeting x86-64, in that the optimiser was assuming that
> floating-point traps were turned off. This was shown, for example, by the
> way it hoisted floating-point divides above tests of the divisor that were
> meant to safeguard the divides.
>
>
>
> After a long support case with Apple, they gave me some Clang command-line
> options for LLVM  that suppressed the problem:
>
>
>
> -mllvm -speculate-one-expensive-inst=false
>
> -mllvm -bonus-inst-threshold=0
>
>
>
> I appreciate that this costs some performance, and I can accept that.
> These options worked fine for Apple Clang 9.x, whose various versions seem
> to have been based on LLVM 4.x and 5.x.
>
>
>
> Now I’ve come to Apple Clang 10.0, which seems to be based on LLVM 6.0.1,
> and I have lots of floating-point traps again in optimised x86-64 code. It
> seems possible that I need some further LLVM options: does this seem
> plausible?
>
>
>
> I’m not familiar with the LLVM codebase, and while I can find the source
> files that list the options I can use with -mllvm, I’d be guessing at which
> options are worth trying. Can anyone make suggestions?
>
>
>
> Thanks very much,
>
>
>
> --
>
> John Dallman
>
> -----------------
> Siemens Industry Software Limited is a limited company registered in
> England and Wales.
> Registered number: 3476850.
> Registered office: Faraday House, Sir William Siemens Square, Frimley,
> Surrey, GU16 8QD.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
>
> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_cfe-2Ddev&d=DwIGaQ&c=slrrB7dE8n7gBJbeO0g-IQ&r=O_4M49EtSpZ_-BQYeigzGv0P4__noMcSu2RYEjS1vKs&m=IC13mZDPBlFkZy7YgY9bDEEcxXgLsKe8iW9CgRH7FAw&s=hyOpVv8agMXpo59RhecwFSIoie-MoFmN-7hxu_fsrbk&e=
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190307/8d69ff28/attachment.html>


More information about the cfe-dev mailing list