<div dir="ltr"><div>Hi JF,</div><div><br></div><div>I've bisected this to PR24535, please try to take a look at it if you get a free moment.</div><div><br></div>Given what Eli brought up, shouldn't we guard it's usage in 64-bit mode on a -mattr flag?  Materializing lahf or sahf without knowing apriori that a CPU can handle it seems problematic.<div><br></div><div>Thanks!</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 12, 2015 at 10:59 AM, JF Bastien via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div class="h5">On Wed, Aug 12, 2015 at 10:53 AM, Reid Kleckner <span dir="ltr"><<a href="mailto:rnk@google.com" target="_blank">rnk@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span>On Mon, Aug 10, 2015 at 5:41 PM, Eli Friedman via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span>On Mon, Aug 10, 2015 at 1:59 PM, JF Bastien via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br></span><div class="gmail_extra"><div class="gmail_quote"><span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: jfb<br>
Date: Mon Aug 10 15:59:36 2015<br>
New Revision: 244503<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=244503&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=244503&view=rev</a><br>
Log:<br>
x86: Emit LAHF/SAHF instead of PUSHF/POPF<br>
<br>
NaCl's sandbox doesn't allow PUSHF/POPF out of security concerns (priviledged emulators have forgotten to mask system bits in the past, and EFLAGS's DF bit is a constant source of hilarity). Commit r220529 fixed PR20376 by saving cmpxchg's flags result using EFLAGS, this commit now generated LAHF/SAHF instead, for all of x86 (not just NaCl) because it leads to an overall performance gain over PUSHF/POPF.<br></blockquote><div><br></div></span><div>There's a problem with this: not all x86 CPUs support lahf/sahf in 64-bit mode.<br></div></div></div></div></blockquote><div><br></div></span><div>Which CPUs don't support lahf/sahf, old ones or new ones? It's basically the only safe way to copy into and out of eflags.</div></div></div></div></blockquote><div><br></div></div></div><div>Old ones: </div></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_extra">"<span style="color:rgb(37,37,37);font-family:sans-serif;font-size:14px;line-height:22.4px">Early AMD64 and Intel 64 CPUs lacked </span><tt style="font-family:monospace,Courier;color:rgb(37,37,37);font-size:14px;line-height:22.4px">LAHF</tt><span style="color:rgb(37,37,37);font-family:sans-serif;font-size:14px;line-height:22.4px"> and </span><tt style="font-family:monospace,Courier;color:rgb(37,37,37);font-size:14px;line-height:22.4px">SAHF</tt><span style="color:rgb(37,37,37);font-family:sans-serif;font-size:14px;line-height:22.4px"> instructions in 64-bit mode. AMD introduced these instructions (also in 64-bit mode) with their Athlon 64, Opteron and Turion 64 revision D processors in March 2005</span><sup style="line-height:1;font-size:11.2px;display:inline-block;color:rgb(37,37,37);font-family:sans-serif"><a href="https://en.wikipedia.org/wiki/X86-64#cite_note-44" style="text-decoration:none;color:rgb(11,0,128);white-space:nowrap;background:none" target="_blank">[44]</a></sup><sup style="line-height:1;font-size:11.2px;display:inline-block;color:rgb(37,37,37);font-family:sans-serif"><a href="https://en.wikipedia.org/wiki/X86-64#cite_note-45" style="text-decoration:none;color:rgb(11,0,128);white-space:nowrap;background:none" target="_blank">[45]</a></sup><sup style="line-height:1;font-size:11.2px;display:inline-block;color:rgb(37,37,37);font-family:sans-serif"><a href="https://en.wikipedia.org/wiki/X86-64#cite_note-46" style="text-decoration:none;color:rgb(11,0,128);white-space:nowrap;background:none" target="_blank">[46]</a></sup><span style="color:rgb(37,37,37);font-family:sans-serif;font-size:14px;line-height:22.4px"> while Intel introduced the instructions with the Pentium 4 G1 stepping in December 2005.</span>"</div><div class="gmail_extra"> - <a href="https://en.wikipedia.org/wiki/X86-64" target="_blank">https://en.wikipedia.org/wiki/X86-64</a></div></blockquote></div>
<br>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div>