<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle18
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">I produce a mathematical modelling library on several platforms, including iOS, macOS and Android, all of which use Clang. Where the hardware can generate floating-point traps, I prefer to run testing with traps for Invalid Operation, Divide-by-Zero
 and Overflow turned on, since that finds me problem sites more quickly than working backwards from “this test case failed.”<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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. <o:p>
</o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">After a long support case with Apple, they gave me some Clang command-line options for LLVM  that suppressed the problem:
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="text-indent:36.0pt">-mllvm -speculate-one-expensive-inst=false
<o:p></o:p></p>
<p class="MsoNormal" style="text-indent:36.0pt">-mllvm -bonus-inst-threshold=0<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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.
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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?
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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?
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks very much, <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;mso-fareast-language:EN-GB">--
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;mso-fareast-language:EN-GB">John Dallman<o:p></o:p></span></p>
</div>
<p style="font-family:Arial; font-size:70%">-----------------<br>
Siemens Industry Software Limited is a limited company registered in England and Wales.<br>
Registered number: 3476850.<br>
Registered office: Faraday House, Sir William Siemens Square, Frimley, Surrey, GU16 8QD.
</p>
</body>
</html>