<div dir="ltr"><div>Thank you Johannes for your suggestion.</div><div><br></div><div>In case a call to the function which would contain the code I would like to paste is inserted into another function, then is it still possible to simply inline the code?</div><div>I would like to avoid calling the function with the "pasted" code. I assume there is a pass which inlines functions which should be executed later.<br></div><div><br></div><div>Thanks,</div><div>Przemek<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jun 2, 2021 at 4:13 AM Johannes Doerfert <<a href="mailto:johannesdoerfert@gmail.com">johannesdoerfert@gmail.com</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">Hi Przemek,<br>
<br>
I doubt that such functionality exists right now. The main<br>
problem I see is the name matching to embed it with other code.<br>
If the new code is not connected, I'd recommend the pass to<br>
read in an IR file with a function in it, link it into the module,<br>
and insert a call wherever you want to "paste" the instructions.<br>
<br>
Much cleaner than dealing with strings, IMHO.<br>
<br>
~ Johannes<br>
<br>
<br>
On 6/1/21 12:16 PM, Przemyslaw Ossowski via llvm-dev wrote:<br>
> Hello,<br>
><br>
><br>
><br>
> I would like to add a pass which modifies IR by insertion set of IR<br>
> instructions somewhere in the middle of the basicblock,<br>
><br>
> like example below:<br>
><br>
><br>
><br>
>    %address = call i32* @llvm.target_intrinsic.getaddress()<br>
><br>
>    %value = load i32, i32* %address<br>
><br>
>    %addvalue = add nsw i32 %value, 10<br>
><br>
>    store i32 %addvalue, i32* %address<br>
><br>
><br>
><br>
> Is there any function available which would allow for parsing the string<br>
> (containing set of instructions) and generating instructions automatically<br>
> instead of manually calling functions creating instructions from IRBuilder?<br>
><br>
> ...at least for simple set of basic instructions<br>
><br>
><br>
> Regards,<br>
><br>
> Przemek<br>
><br>
><br>
> _______________________________________________<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>