[LLVMdev] Accessing a custom defined llvm pass

Adam Taylor aktaylor08 at gmail.com
Wed Feb 25 09:30:36 PST 2015


Hi John,

Thanks.  That was the problem exactly.  I had declared the pass classes in
an anonymous namespace in a header file and also tried to set the
ParamCallFinder::ID within the header file as well which is not allowed/had
no effect in C++ from what I can gather (I'm not the most familiar with
C++).   I removed the anonymous namespace and set the ParamCallFinderID in
the c++ file with it's implementation and everything worked great.

 I have one further question that has to do with how C++/llvm handles the
anonymous namespaces.  Are they required when declaring function passes or
is my solution okay?  If they anonymous namespaces are needed how can I
access the ParamCallFinder::ID outside of the header file and in the C++
implementation?

Thanks,
Adam Taylor

On Wed, Feb 25, 2015 at 7:45 AM, John Criswell <jtcriswel at gmail.com> wrote:

>  On 2/23/15 10:26 PM, Adam Taylor wrote:
>
> Hello all,
>
>  I have written one pass to collect information about specific calls in
> an llvm IR file and am not trying to reference the results from the first
> pass in a second pass.
>
>  What is the correct way to reference an additional custom pass in LLVM?
> At the moment the project is set up under the lib/Transforms directory in
> source and has the current layout:
>
>  Thresholds/
>     include/
>         Thresholds.h
>     Pass1.cpp
>     Pass2.cpp
>     Makefile
>
>  Both of the pass classes are defined in the header file.  In pass two I
> have declared that it requires Pass1 using: AU.addRequired<Pass1>() and get
> the result using
> getAnalysis<Pass1>().getParamPtrs();
>
>  The module compiles correctly, but when trying to load it using opt I
> get an error:
>
>  Error opening 'Thresholds.dylib': dlopen(Thresholds.dylib, 9): Symbol
> not found: __ZN12_GLOBAL__N_115ParamCallFinder2ID
>
>  What is the correct way to reference another custom written pass in
> LLVM?  Is is possible to do it in this manner or am I completly wrong in my
> approach?
>
>
> I don't think there's enough information in this email to determine,
> reliably, what the problem is.  That said, I'm guessing that one of your
> passes is named ParamCallFinder.
>
> If I'm correct, make sure that ParamCallFinder::ID is defined in the .cpp
> file that defines the methods for the pass.  Otherwise, the ID will be
> declared but not defined, and you can get a link error like the one you're
> seeing.
>
> I can't be sure, but I suspect that's the problem.
>
> Regards,
>
> John Criswell
>
>
>
>  Thanks!
>
>
> _______________________________________________
> 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/20150225/0e9e374d/attachment.html>


More information about the llvm-dev mailing list