<div dir="ltr"><div><br></div><div class="gmail_extra"><div class="gmail_quote">On 5 November 2014 19:55, Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The final lowering has to happen fairly late as the linker depends on<br>
doing pattern matching for optimizing the different access.<br></blockquote><div><br></div><div>I see. That explains why it's expanded in AsmPrinter. And maybe even the reason why in some cases there is also some padding between the instructions (I imagine the linker would patch it up, right?).</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Maybe instead of having a TLS_addr64 pseudo we could have it be an<br>
actual call to an intrinsic and then special case the MC lowering</blockquote><div><br></div><div>Hm... that would require some reworking in the places where the pseudo instruction is handled, but it sounds like a good direction to investigate. I'll have a look at how to implement that.</div><div><br></div><div>Cheers,</div><div>    Dario Domizioli</div><div>    SN Systems - Sony Computer Entertainment Group</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
that call? That is, instead of having the X86::TLS_addr64 opcode,<br>
X86AsmPrinter::EmitInstruction would check the operands of a call to<br>
check if it should use LowerTlsAddr.<br>
<div><div class="h5"><br>
On 5 November 2014 09:57, Dario Domizioli <<a href="mailto:dario.domizioli@gmail.com">dario.domizioli@gmail.com</a>> wrote:<br>
> Hello llvm-dev,<br>
><br>
> I am trying to fix PR20243.<br>
> The main issue seems to be that the compiler is using a pseudo-instruction<br>
> to express a TLS global access (in PIC mode on X86 ELF) and that masks the<br>
> fact that a library call has to be performed. The pseudo-instruction is only<br>
> lowered in the AsmPrinter, too late for any code that checks whether the<br>
> function containing the instruction is a leaf function. This affects the<br>
> decision whether to eliminate the frame pointer in the "eliminate frame<br>
> pointer only for leaf functions" case.<br>
><br>
> I have prepared a patch, and my intention was to mark the TLS access<br>
> pseudo-instructions with the "isCall" flag, so that they would be recognized<br>
> as calls.<br>
> However I ran into a problem: the (I believe recently introduced) "FP<br>
> Stackify" pass tries to interpret the pseudo-instruction as a proper call<br>
> and it tries to get the return registers, but then it asserts because it<br>
> gets utterly confused by the pseudo-instruction.<br>
> So, to try to solve this, I had to add the "isPseudo" flag to the<br>
> instruction, and modify the "FP Stackify" pass to ignore call instructions<br>
> that are also pseudo (a one-line change).<br>
><br>
> This problem suggests to me however that this is probably not the right way<br>
> to approach the original problem. It's not a good sign if I'm breaking<br>
> things in the process of fixing other stuff.<br>
><br>
> I'm attaching my patch. I would gladly accept any advice on the matter. Am I<br>
> attacking the issue from the right direction? Is the "isCall" flag the right<br>
> way to express what the pseudo-instruction does? Or is the usage of a<br>
> pseudo-instruction itself wrong, and should it be lowered in ISel instead of<br>
> the AsmPrinter?<br>
><br>
> Cheers,<br>
>     Dario Domizioli<br>
>     SN Systems - Sony Computer Entertainment Group<br>
><br>
><br>
</div></div>> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
><br>
</blockquote></div><br></div></div>