<div dir="ltr"><div>Thanks,</div><div>but when I went into details I'm wondering if using linker in a simple pass is possible.</div><div>Usually passes are executed per module.</div><div> Is it possible to use linker and later replace the original module with a newly linked module in simple pass?</div><div>Module is passed by reference to runOnModule, so probably it should be possible...<br></div><div></div><div><br></div><div>Przemek</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jun 8, 2021 at 6:01 PM 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">If you insert a call prior to the inliner and mark it with the<br>
`alwaysinline` attribute, it will be inlined for sure.<br>
<br>
Reduces your problem to insert a call to a function :)<br>
<br>
~ Johannes<br>
<br>
<br>
On 6/7/21 10:51 AM, Przemyslaw Ossowski wrote:<br>
> Thank you Johannes for your suggestion.<br>
><br>
> In case a call to the function which would contain the code I would like to<br>
> paste is inserted into another function, then is it still possible to<br>
> simply inline the code?<br>
> I would like to avoid calling the function with the "pasted" code. I assume<br>
> there is a pass which inlines functions which should be executed later.<br>
><br>
> Thanks,<br>
> Przemek<br>
><br>
><br>
> On Wed, Jun 2, 2021 at 4:13 AM Johannes Doerfert <<a href="mailto:johannesdoerfert@gmail.com" target="_blank">johannesdoerfert@gmail.com</a>><br>
> wrote:<br>
><br>
>> 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<br>
>> automatically<br>
>>> instead of manually calling functions creating instructions from<br>
>> IRBuilder?<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>