<div dir="ltr">Hello Jessica,<div><br></div><div>I tried running my pass in the PreEmit phase in X86. It doesn't maintain the alignment of stack pointer. I tried with PreRegAlloc phase and I got into an error of insufficient register allocation. If I reduce my register usage, source code can be compiled, but when the generated machine code is run, I still get segmentation fault.</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Regards,<div>Soham Sinha</div><div>PhD Student, Department of Computer Science</div><div>Boston University</div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Mon, May 7, 2018 at 12:08 PM, Jessica Paquette <span dir="ltr"><<a href="mailto:jpaquette@apple.com" target="_blank">jpaquette@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">One place to look might be in the MachineOutliner target hooks in X86InstrInfo and AArch64InstrInfo. The MachineOutliner runs extremely late in the pass pipeline so it might be a good place to look for some inspiration. Of course, because this is *extremely late* it might not do *exactly* what you need. (e.g, this is post-register allocation, post frame-lowering, etc.)<br>
<br>
- Jessica<br>
<div><div class="h5"><br>
> On May 4, 2018, at 6:32 PM, Soham Sinha via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
> <br>
> Hello,<br>
> <br>
> I want to add assembly instructions at certain points in a function. This is X86 specific. So I am working in the lib/Target/X86 folder. I create a `MachineFunctionPass` in that folder. I register it in the X86TargetMachine.cpp in addPreEmitPass(). I use BuildMI to insert my own assembly instructions in the MachineFunctionPass. This works and my assembly instructions are inserted at desired places. However, this breaks the alignment. So when I run the generated code, I get segmentation fault (precisely in printf with XMM registers). Where should I add my pass? <br>
> <br>
> My pass depends on the MachineBasicBlock information as well. Therefore, I cannot add my pass too early in LLVM IR. What is the proper pass to add my custom MachineFunctionPass? I tried addPreRegAlloc, but it failed due to insufficient register allocation error or something on that line.<br>
> <br>
> Can anybody please help me write a MachineFunctionPass where I can insert assembly instruction without breaking the alignment? I am doing this for X86_64.<br>
> <br>
> Regards,<br>
> Soham Sinha<br>
> PhD Student, Department of Computer Science<br>
> Boston University<br>
</div></div>> ______________________________<wbr>_________________<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/<wbr>mailman/listinfo/llvm-dev</a><br>
<br>
</blockquote></div><br></div>