Shishir V Jessu via llvm-dev
2020-Mar-16 22:45 UTC
[llvm-dev] Passing arguments to LLVM pass through Clang
Hello, I am adding to an LLVM pass that requires a filename as input. I am able to input this filename as a command line argument when I invoke this pass using opt, but I ultimately need to pass this argument to my code when I compile code with clang. How can I pass this argument to clang so that I can use it in my LLVM pass? Thanks for your help! Best, Shishir Jessu -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200316/558b1711/attachment.html>
Benno Krauss via llvm-dev
2020-Mar-17 07:48 UTC
[llvm-dev] Passing arguments to LLVM pass through Clang
Hello Shishir, To pass arguments to LLVM from clang, use something like `clang source.c -mllvm -customarg -mllvm argvalue`. The -mllvm argument tells clang to forward the following argument to LLVM. Similarly, there is the -Xclang argument to pass the following argument to clang proper, as opposed to the clang driver. Cheers, Benno Am 16.03.2020 um 23:45 schrieb Shishir V Jessu via llvm-dev <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>>: Hello, I am adding to an LLVM pass that requires a filename as input. I am able to input this filename as a command line argument when I invoke this pass using opt, but I ultimately need to pass this argument to my code when I compile code with clang. How can I pass this argument to clang so that I can use it in my LLVM pass? Thanks for your help! Best, Shishir Jessu [https://my-email-signature.link/signature.gif?u=452460&e=89920299&v=06d9a9b1e5d7f6685284ae9f5a944df07b26d3dc9391d3cecc31b2e77d4f5d20] _______________________________________________ LLVM Developers mailing list llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Shishir V Jessu via llvm-dev
2020-Mar-17 18:22 UTC
[llvm-dev] Passing arguments to LLVM pass through Clang
Hi Benno, Thanks for your response! Unfortunately, I don't think the -mllvm flag is doing what I need. Specifically, I am adding to the LowerTypeTests optimization pass in LLVM. When I invoke this pass with opt, there is a command line option called " lowertypetests-read-summary", which allows me to specify a file name. I've added a similar option, that takes a filename as input and opens that file to obtain some information necessary to do the pass. It looks like -lowertypetests is not a pass that -mllvm recognizes, so I'm not able to input arguments to this pass using -mllvm. In fact, it doesn't seem like *any* of the passes that -mllvm recognizes can be invoked with opt. Do you know if there's some code I can modify that will allow -mllvm to recognize this pass? Or is there a better way to get clang to send the filename input to my pass? Thanks so much for your help! Best, Shishir Jessu On Tue, Mar 17, 2020 at 2:48 AM Benno Krauss <benno.krauss at wibu.com> wrote:> Hello Shishir, > > To pass arguments to LLVM from clang, use something like `clang source.c > -mllvm -customarg -mllvm argvalue`. The -mllvm argument tells clang to > forward the following argument to LLVM. Similarly, there is the -Xclang > argument to pass the following argument to clang proper, as opposed to the > clang driver. > > Cheers, > Benno > > Am 16.03.2020 um 23:45 schrieb Shishir V Jessu via llvm-dev < > llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>>: > > Hello, > > I am adding to an LLVM pass that requires a filename as input. I am able > to input this filename as a command line argument when I invoke this pass > using opt, but I ultimately need to pass this argument to my code when I > compile code with clang. > > How can I pass this argument to clang so that I can use it in my LLVM > pass? Thanks for your help! > > Best, > Shishir Jessu > [ > https://my-email-signature.link/signature.gif?u=452460&e=89920299&v=06d9a9b1e5d7f6685284ae9f5a944df07b26d3dc9391d3cecc31b2e77d4f5d20] > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org> > https://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/20200317/33bef89f/attachment.html>