Hi. I need to write a function pass that insert nop instruction in function. Examples of these instructions are: %nop = add i1 0, 0 or %nop = alloca i1, i1 0. This link couldn't help me: http://llvm.org/docs/ProgrammersManual.html#creating-and-inserting-new-instructions I need a clear example about inserting new instruction. Anyone can help me? Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150709/5d246596/attachment.html>
Hi Zahra, What the problem do you have? Could you provide your code? Kind regards, Evgeny Astigeevich From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Zahra Marj Sent: 09 July 2015 09:25 To: LLVM Developers Mailing List Subject: [LLVMdev] insert nop instruction Hi. I need to write a function pass that insert nop instruction in function. Examples of these instructions are: %nop = add i1 0, 0 or %nop = alloca i1, i1 0. This link couldn't help me: http://llvm.org/docs/ProgrammersManual.html#creating-and-inserting-new-instructions <https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_docs_ProgrammersManual.html-23creating-2Dand-2Dinserting-2Dnew-2Dinstructions&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=qXjJRaqkQWeOVtPcUv65c1zR2hwz2FyxkyPKUDcEsBM&s=CnMC85PvQDV1ouDHE2aQz5LytBiguUJ3JiOkMez73dg&e=> I need a clear example about inserting new instruction. Anyone can help me? Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150709/edc9f371/attachment.html>
Hi, What are you trying to achieve? Inserting NOPs into LLVM IR is likely to be pointless, as optimisations (in the IR or SelectionDAG) will remove them before machine code generation. If you want to insert NOPs into the generated machine code, then this will not help you (you could insert inline assembly containing nops into the IR). David> On 9 Jul 2015, at 09:25, Zahra Marj <zahrafatehimarj at gmail.com> wrote: > > Hi. > I need to write a function pass that insert nop instruction in function. Examples of these instructions are: %nop = add i1 0, 0 or %nop = alloca i1, i1 0. This link couldn't help me: http://llvm.org/docs/ProgrammersManual.html#creating-and-inserting-new-instructions > I need a clear example about inserting new instruction. Anyone can help me? > Thanks. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
I would like to use "new instruction()" or similar instruction that generate an NOP instruction and then insert it, randomly, between instructions of function basic blocks. But link doesn't provide a good example and limits to alloca instruction. On Thu, Jul 9, 2015 at 1:05 PM, Evgeny Astigeevich < evgeny.astigeevich at arm.com> wrote:> Hi Zahra, > > > > What the problem do you have? > > Could you provide your code? > > > > Kind regards, > > Evgeny Astigeevich > > > > *From:* llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] *On > Behalf Of *Zahra Marj > *Sent:* 09 July 2015 09:25 > *To:* LLVM Developers Mailing List > *Subject:* [LLVMdev] insert nop instruction > > > > Hi. > > I need to write a function pass that insert nop instruction in function. > Examples of these instructions are: %nop = add i1 0, 0 or %nop = alloca i1, > i1 0. This link couldn't help me: > http://llvm.org/docs/ProgrammersManual.html#creating-and-inserting-new-instructions > <https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_docs_ProgrammersManual.html-23creating-2Dand-2Dinserting-2Dnew-2Dinstructions&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=qXjJRaqkQWeOVtPcUv65c1zR2hwz2FyxkyPKUDcEsBM&s=CnMC85PvQDV1ouDHE2aQz5LytBiguUJ3JiOkMez73dg&e=> > > I need a clear example about inserting new instruction. Anyone can help me? > > Thanks. >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150709/76d642e6/attachment.html>
My pass runs after optimization passes. On Thu, Jul 9, 2015 at 1:11 PM, David Chisnall <David.Chisnall at cl.cam.ac.uk> wrote:> Hi, > > What are you trying to achieve? Inserting NOPs into LLVM IR is likely to > be pointless, as optimisations (in the IR or SelectionDAG) will remove them > before machine code generation. If you want to insert NOPs into the > generated machine code, then this will not help you (you could insert > inline assembly containing nops into the IR). > > David > > > On 9 Jul 2015, at 09:25, Zahra Marj <zahrafatehimarj at gmail.com> wrote: > > > > Hi. > > I need to write a function pass that insert nop instruction in function. > Examples of these instructions are: %nop = add i1 0, 0 or %nop = alloca i1, > i1 0. This link couldn't help me: > http://llvm.org/docs/ProgrammersManual.html#creating-and-inserting-new-instructions > > I need a clear example about inserting new instruction. Anyone can help > me? > > Thanks. > > _______________________________________________ > > LLVM Developers mailing list > > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150709/19bca1c9/attachment.html>