I would like to convert a C file that uses OpenMP library to X86 code with a condition: I want to insert a NOP before each instruction that does a private memory access.I have written an optimization pass that inserts an inline assembly call (NOP) but it is applied at IR level, and I cannot determine where to insert it. How can I use LLVM to add NOPs accordingly? Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150915/6d1c13cf/attachment.html>
Hi Erdem, I would write a MachineFunction pass. You can check each load instruction to see if it is a private memory access and insert what you want by using BuildMI(...) function. Volkan On Tue, Sep 15, 2015 at 4:16 AM Erdem Derebaşoğlu <llvm-dev at lists.llvm.org> wrote:> I would like to convert a C file that uses OpenMP library to X86 code with > a condition: I want to insert a NOP before each instruction that does a > private memory access. > I have written an optimization pass that inserts an inline assembly call > (NOP) but it is applied at IR level, and I cannot determine where to insert > it. How can I use LLVM to add NOPs accordingly? > > Thanks. > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150915/f258df13/attachment.html>
Use MachineInstr::memoperands() function to get memory operands then you can get the address space by using MachineMemOperand::getAddrSpace(). Volkan On Tue, Sep 15, 2015 at 11:40 PM Erdem Derebaşoğlu < erdemderebasoglu at hotmail.com> wrote:> Thanks for the response. How can I find out if an instruction uses a > private memory access? > > Erdem > ------------------------------ > From: vlknkls at gmail.com > Date: Tue, 15 Sep 2015 14:38:16 +0000 > Subject: Re: [llvm-dev] How to add NOP? > To: erdemderebasoglu at hotmail.com; llvm-dev at lists.llvm.org > > > Hi Erdem, > > I would write a MachineFunction pass. You can check each load instruction > to see if it is a private memory access and insert what you want by using > BuildMI(...) function. > > Volkan > > On Tue, Sep 15, 2015 at 4:16 AM Erdem Derebaşoğlu <llvm-dev at lists.llvm.org> > wrote: > > I would like to convert a C file that uses OpenMP library to X86 code with > a condition: I want to insert a NOP before each instruction that does a > private memory access. > I have written an optimization pass that inserts an inline assembly call > (NOP) but it is applied at IR level, and I cannot determine where to insert > it. How can I use LLVM to add NOPs accordingly? > > Thanks. > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150916/6f69c828/attachment.html>
This seems to be what I am looking for. That was very helpful. Thank you. Erdem From: vlknkls at gmail.com Date: Wed, 16 Sep 2015 16:25:29 +0000 Subject: Re: [llvm-dev] How to add NOP? To: erdemderebasoglu at hotmail.com; llvm-dev at lists.llvm.org Use MachineInstr::memoperands() function to get memory operands then you can get the address space by using MachineMemOperand::getAddrSpace(). Volkan On Tue, Sep 15, 2015 at 11:40 PM Erdem Derebaşoğlu <erdemderebasoglu at hotmail.com> wrote: Thanks for the response. How can I find out if an instruction uses a private memory access? Erdem From: vlknkls at gmail.com Date: Tue, 15 Sep 2015 14:38:16 +0000 Subject: Re: [llvm-dev] How to add NOP? To: erdemderebasoglu at hotmail.com; llvm-dev at lists.llvm.org Hi Erdem, I would write a MachineFunction pass. You can check each load instruction to see if it is a private memory access and insert what you want by using BuildMI(...) function. Volkan On Tue, Sep 15, 2015 at 4:16 AM Erdem Derebaşoğlu <llvm-dev at lists.llvm.org> wrote: I would like to convert a C file that uses OpenMP library to X86 code with a condition: I want to insert a NOP before each instruction that does a private memory access.I have written an optimization pass that inserts an inline assembly call (NOP) but it is applied at IR level, and I cannot determine where to insert it. How can I use LLVM to add NOPs accordingly? Thanks. _______________________________________________ LLVM Developers mailing list llvm-dev at lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150917/612ceecc/attachment.html>