<div dir="ltr">Hey, <div><br></div><div>I'm probably not the best person to answer this, but I'll say something in case no one else does b/c something is better than nothing. I noticed you re-asked your question, so I'm replying on the older one in case someone more qualified sees the more recent one.</div><div><br></div><div>I'm going to assume by "intrinsic" you mean an llvm intrinsic function. If you're asking your question here, it sounds like you probably already tried inserting your intrinsic function as the first IR instruction, looked at the assembly and noticed that your instruction/instruction sequence isn't the first one in the function. It's possible that there's a way to do it in IR, but if there is, idk how to do it.</div><div><br></div><div>If I were to do it, I'd use a machine function pass like you suggest and instead of an intrinsic create and insert the instruction as part of the last pass in the codegen process (end of preEmit2 in x86). That way you have total control where the instruction goes and know nothing in the codegen process is going to move it.</div><div><br></div><div>MachineFunction passes sound scary, but here's a pretty pain-free link for how to write your first one: <a href="https://www.kharghoshal.xyz/blog/writing-machinefunctionpass" target="_blank">https://www.kharghoshal.xyz/blog/writing-machinefunctionpass</a>. It's for x86, but I'm sure you could do the same thing for RISC-V. There's one typo: " In the pass's .cpp file "createX86MachineInstrPrinter<b>Pass</b>" is defined, and in the other files "createX86MachineInstrPrinter" is used." They just need to be the same.</div><div><br></div><div>All the best.</div><div><br></div><div>Regards,</div><div><br></div><div>Armand</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, May 3, 2021 at 12:03 PM Sai Venkata Krishnan V via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello Everyone<div> I have create a new intrinsic in RISCV and I am trying to insert it at the start of every function based on Command-Line argument which determines the list of functions to omit. I expect this intrinsic to be inserted at the start of function as first instruction. Is this possible with a normal Module pass using opt command? Or, should I look into MachineFunction pass?</div><div>Please guide me in this.</div><div><br></div><div>Thanking you</div><div>Sai</div></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>