<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">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 class="">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>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 id="cite_ref-44" class="reference" 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">[44]</a></sup><sup id="cite_ref-45" class="reference" 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">[45]</a></sup><sup id="cite_ref-46" class="reference" 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">[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">https://en.wikipedia.org/wiki/X86-64</a></div></blockquote></div>