<div dir="ltr"><div><div>Dear John and Jim,<br>Thanks for your answers.<br></div>I agree that it is easy to do option 1 below and simple to use the stack as John suggests, and maybe a bit more difficult when using RegisterScavenger.<br></div><div>However, I was just wondering maybe "Undoing the Register Allocation" has already been done as part of some LLVM-based disassembler.<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 23, 2014 at 12:23 PM, John Criswell <span dir="ltr"><<a href="mailto:jtcriswel@gmail.com" target="_blank">jtcriswel@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"><span class="">
<div>On 9/23/14, 11:14 AM, Rahman Lavaee
wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div>
<div>Thanks John,<br>
<br>
</div>
The reason I want to do this is that register allocator works
only on SSA form, and if you instrument regallocated code with
non-regallocated machine instructions, then you cannot
regallocate the result.<br>
<br>
</div>
A workaround is to assign physical registers while doing the
instrumentation, which I don't think is as easy as the above.<br>
</div>
</blockquote>
<br></span>
Actually, it is pretty simple as long as you don't care about
performance. All you have to do is insert code to push the
registers that you want to use on to the stack, use those registers
in your instrumentation, and then restore them with pops off the
stack.<br>
<br>
Regards,<br>
<br>
John Criswell<span class=""><br>
<blockquote type="cite">
<div class="gmail_extra"><br>
<div class="gmail_quote">On Tue, Sep 23, 2014 at 11:01 AM, John
Criswell <span dir="ltr"><<a href="mailto:jtcriswel@gmail.com" target="_blank">jtcriswel@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On 9/23/14, 10:52 AM, Rahman Lavaee wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
I'm wondering how I can convert "register allocated"
code back to SSA form. I realized from
MachineRegisterInfo.h that a function leaves SSA form
only once and cannot be taken back to it.<br>
</blockquote>
<br>
</span>
Are you wanting to put MachineInstr's into SSA form? If you
want to do that, you'll need to implement the SSA
construction algorithm yourself so that it works on
MachineInstrs. Also, such a pass will need to work with
virtual registers as you'll need an unlimited supply of
temporary variables. In essence, you'll be undoing register
allocation.<br>
<br>
Can you describe why you want to put MachineInstrs into SSA
form? I suspect that putting MachineIntrs back into SSA
form is not what you want to do.<br>
<br>
Regards,<br>
<br>
John Criswell<br>
<br>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</span></div>
</blockquote></div><br></div>