<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 29, 2016 at 2:06 PM, Fabio Pagani via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hello llvm-dev list,<br><br>i am implementing an X86 Machine Pass that at some point needs to push/pop eflags on the stack. This pass is hooked at preRegAlloc and LLVM is 3.7.0.<br>I got two big problems:<br>1) I didn't found a way to emit a pushfq instruction in a clean way, i.e. with   BuildMI(*MBB, MI, DL, TII.get(X86::PUSHF64)). Even if both EFLAGS and RSP are added to the MBB liveins, the Machine Verifier complains saying:<div><div>*** Bad machine code: Using an undefined physical register ***                                  </div><div>- function:    main                                                                                              </div><div>- basic block: BB#238 for.inc.121.4 (0x43133b0)</div><div>- instruction: PUSHF64- operand 2:   %EFLAGS<imp-use,kill>   <br></div></div></div></blockquote><div><br></div><div>We had a similar issue with the machine verifier for our blessed intrinsic.</div><div>The fixe was to mark the EFLAGS MachineOperand as Undef: <a href="https://github.com/llvm-mirror/llvm/commit/60cefca131b1e4847f7206f99f334baac95772e9">https://github.com/llvm-mirror/llvm/commit/60cefca131b1e4847f7206f99f334baac95772e9</a></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div><br>Anyway right now i'm able to push it via some "dirty" INLINE_ASM.<br><br>2) INLINE_ASM works pretty well, except in one randomly generated test case where the register allocator spills a register in between the pushfq/popfq, resulting in a crash of the compiled application. <br><br>So the question is: is there a recommended way to save and restore the value of eflags?<br><br>Any help is really appreciated! <br></div></div></div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div></div>