[LLVMdev] insert nop instruction

Zahra Marj zahrafatehimarj at gmail.com
Fri Jul 10 14:28:50 PDT 2015


Thanks all. Your comments help me very much.

On Thu, Jul 9, 2015 at 6:57 PM, John Criswell <jtcriswel at gmail.com> wrote:

>  Dear All,
>
> To add to this, you can find examples of inserting NOPs for X86 in the CFI
> pass originally written at Lehigh University that we ported to 64-bit X86
> for SVA:
>
>
> https://github.com/jtcriswell/SVA/blob/master/llvm/lib/Target/X86/X86CFIOptPass.cpp
>
> Alternatively, you could use an InlineAsm call at the LLVM IR level (which
> I think would be easier to implement).
>
> Regards,
>
> John Criswell
>
>
> On 7/9/15 8:56 AM, Daniel Sanders wrote:
>
>  Hi,
>
>
>
> Given that you are using LLVM-IR, I expect that instruction selection
> occurs after your pass and instruction selection also applies
> optimizations. In particular, when the SelectionDAG is built it will
> eliminate (via constant folding) the '%nop = add i1 0, 0' you added to the
> LLVM-IR.
>
>
>
> If you are trying to insert nop's into the resulting assembly then you
> should probably be trying to insert them at a very late stage of the
> backend instead. Different IR's based on MachineInstr and MCInst are used
> in these later stages.
>
>
>
> *From:* llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu
> <llvmdev-bounces at cs.uiuc.edu>] *On Behalf Of *Zahra Marj
> *Sent:* 09 July 2015 12:33
> *To:* David Chisnall
> *Cc:* LLVM Developers Mailing List
> *Subject:* Re: [LLVMdev] insert nop instruction
>
>
>
> 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
> <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=Qp9GWIWeL3Bal7o2P67hp2QbDCZLKBcsuzuT3xzMMUo&s=GZrVdTwGMs5jykSuspIi7GRCIni6kaJDICG65OxeZMc&e=>
> > 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
>
>
>
>
> _______________________________________________
> LLVM Developers mailing listLLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.eduhttp://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
>
> --
> John Criswell
> Assistant Professor
> Department of Computer Science, University of Rochesterhttp://www.cs.rochester.edu/u/criswell
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150711/840f48d7/attachment.html>


More information about the llvm-dev mailing list