<div dir="ltr"><div><div><div><div>Hi Andy and list,<br><br>Just to give you a follow up, I was implementing a transformation pass just as you recommended at the time I sent the email to the list, but at that time I was worried that the code generator would change the order of the instructions created in the LLVM-IR. Indeed, that was the case.<br>
<br></div>Some instructions after ISel were added between the volatile store instructions (which is perfectly OK). To solve this, I created a Machine Function pass that runs right after ISel and just before RA, reordering the insts added by ISel. After that, the RA correctly fixes any register reference in the generated code.<br>
<br></div>The only problem with this approach is that some SSA and Late machine optimizations break the ordering I need. Thus, I am not able to use them yet. However, I am pretty happy with the results so far.<br><br><br>
</div>Thank you!<br></div>ronaldo<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-04-14 20:36 GMT+02:00 Andrew Trick <span dir="ltr"><<a href="mailto:atrick@apple.com" target="_blank">atrick@apple.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
On Apr 10, 2014, at 1:37 PM, Ronaldo Ferreira <<a href="mailto:ronaldorferreira@gmail.com">ronaldorferreira@gmail.com</a>> wrote:<br>
<br>
> Hi,<br>
><br>
> I need to force all variables of a basic block to spill, i.e., I can't allow basic blocks to share registers. I would like to know where is the most appropriate approach to implement that policy in LLVM.<br>
><br>
> Looking at the LLVM source, it seems that the register allocator is the best choice because it controls the spilling, but I need to guarantee that this policy is not violated by post RA passes.<br>
><br>
> To illustrate the policy, let us suppose two BBs A and B:<br>
><br>
> BB A:<br>
> a = x + y<br>
><br>
> BB B:<br>
> b = a * x<br>
><br>
> In a pseudo machine code, I need to generate this:<br>
><br>
> BB A:<br>
> load x;<br>
> load y;<br>
> add a, x, y<br>
> store a<br>
><br>
> BB B:<br>
> load a;<br>
> load x;<br>
> mul b, a, x;<br>
> store b;<br>
><br>
><br>
> Any help is much appreciated!<br>
<br>
My first thought is to add an IR pass that generates volatile loads and stores for live-in/out values. There may be more clever ways of doing this though.<br>
-Andy<br>
<br>
><br>
> Thanks,<br>
> Ronaldo<br>
> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br>
</blockquote></div><br></div>