[llvm-dev] Passing arguments to LLVM pass through Clang

Andrzej Warzynski via llvm-dev llvm-dev at lists.llvm.org
Tue Mar 17 12:26:03 PDT 2020


Hi Shishir,

How are you adding/registering your pass? Perhaps you're loading your 
pass dynamically? Which pass manager are you using?

Certain things work differently depending on whether you're linking your 
pass statically, or loading it dynamically. Also, there are subtle 
differences between the new and legacy pass managers.

-Andrzej

On 17/03/2020 18:22, Shishir V Jessu via llvm-dev wrote:
> 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 
> <mailto: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><mailto: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><mailto:llvm-dev at lists.llvm.org
>     <mailto:llvm-dev at lists.llvm.org>>
>     https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> 
> 
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> 


More information about the llvm-dev mailing list