[LLVMdev] Is it possible to use EE within optimization pass?

bhavani krishnan bhavi63 at yahoo.com
Tue Oct 28 14:27:22 PDT 2008


Thanks Nick and others who replied. I just fixed the issue. I compiled opt by linking executionengine into it and now I am able to create jit from within the optimization pass.


--- On Mon, 10/27/08, Nick Lewycky <nicholas at mxc.ca> wrote:

> From: Nick Lewycky <nicholas at mxc.ca>
> Subject: Re: [LLVMdev] Is it possible to use EE within optimization pass?
> To: bhavi63 at yahoo.com, "LLVM Developers Mailing List" <llvmdev at cs.uiuc.edu>
> Date: Monday, October 27, 2008, 4:36 PM
> bhavani krishnan wrote:
> > I realize my questions may not have been so clear. To
> give more details. I am writing a fuction pass. I want to
> interpret some of the instructions within the function pass.
> In order to do so, I need to create an EE object within the
> function pass. Now, If I compile and execute using opt. I
> get an error(Error loading symbol) at the line where I am
> creating EE. 
> > opt: symbol lookup error:
> ../../../build/Release/lib/Try.so: undefined symbol:
> _ZN4llvm15ExecutionEngine6createEPNS_14ModuleProviderEbPSs
> 
> > So, I thought I need to link the EE library files as
> it is not able to load EE. In order to do so, I added the
> line LINK_COMPONENTS=engine to the Makefile. Now, when I
> execute using opt, I get the error that the pass is
> registered multiple times. I know that there has to be a way
> out of this. Please let me know how I should link/load the
> EE library files with my optimization pass.
> 
> Make sure you aren't linking both your pass against the
> EE and the opt 
> program against the EE.
> 
> > I hope the question is clear now. Sorry for repeating
> so many times.
> 
> If you're in a rush, I suggest that you just drop
> 'opt' and build your 
> own standalone opt-like program which is linked against the
> execution 
> engine and your optimization pass (ie., not using -load)
> and whatever 
> other things you need. I also suggest linking with
> LINK_COMPONENTS=all, 
> since that mysteriously seems to avoid all linker errors.
> 
> Otherwise, you may want to try tracking down which pass is
> being 
> registered multiple times, and work backwards to find out
> which file is 
> getting linked twice. I wouldn't approach this from the
> angle that 
> you're doing anything wrong. Rather, assume that
> LLVM's dependencies and 
> LINK_COMPONENTS system is buggy and try to figure out how
> and why.
> 
> Hope that helps.
> Nick Lewycky
> 
> > thanks,
> > Bhavani
> > 
> > 
> > --- On Mon, 10/27/08, John Criswell
> <criswell at cs.uiuc.edu> wrote:
> > 
> >> From: John Criswell <criswell at cs.uiuc.edu>
> >> Subject: Re: [LLVMdev] Is it possible to use EE
> within optimization pass?
> >> To: "bhavi63 at yahoo.com"
> <bhavi63 at yahoo.com>
> >> Cc: "LLVM Developers Mailing List"
> <llvmdev at cs.uiuc.edu>
> >> Date: Monday, October 27, 2008, 3:22 PM
> >> bhavani krishnan wrote:
> >>> Thanks John! My pass is registered only in 1
> cpp file.
> >> It registers and executes fine without the EE.
> >>> I only get the Pass registered multiple times
> error
> >> when I try to link to the EE by using
> LINK_COMPONENTS=engine
> >> in the Makefile. Without that line in the
> Makefile, my pass
> >> gets registered fine but it is not able to create
> EE(Error
> >> reading Symbol). So, how do I link
> LLVMExecutionEngine.o
> >> without causing the multiple registration error.
> >>>   
> >> Just to make sure we've covered all the
> obvious stuff,
> >> are you sure that 
> >> the name of your pass (the name you use when you
> execute it
> >> with the opt 
> >> command) is unique?  Is the class name of your
> pass unique?
> >>
> >> -- John T.
> >>
> >>> thanks,
> >>> Bhavani
> >>>
> >>> --- On Mon, 10/27/08, John Criswell
> >> <criswell at cs.uiuc.edu> wrote:
> >>>   
> >>>> From: John Criswell
> <criswell at cs.uiuc.edu>
> >>>> Subject: Re: [LLVMdev] Is it possible to
> use EE
> >> within optimization pass?
> >>>> To: "bhavi63 at yahoo.com"
> >> <bhavi63 at yahoo.com>, "LLVM Developers
> Mailing
> >> List" <llvmdev at cs.uiuc.edu>
> >>>> Date: Monday, October 27, 2008, 3:01 PM
> >>>> bhavani krishnan wrote:
> >>>>     
> >>>>> Hi all,
> >>>>>
> >>>>> I am repeating my question from
> yesterday coz
> >> I need
> >>>>>       
> >>>> to find a solution to this ASAP. 
> >>>>     
> >>>>> How do I link the executionengine to
> an
> >> optimization
> >>>>>       
> >>>> pass. If I use LINK_COMPONENTS=engine in
> the
> >> Makefile, I get
> >>>> the Pass registered multiple times error.
> And if i
> >> dont use
> >>>> anything, it is not able to load the EE.
> It gives
> >> error
> >>>> loading symbol error. So,
> >>>>     
> >>>>> 1. Is it possible to use the EE within
> an
> >> optimization
> >>>>>       
> >>>> pass?
> >>>>     
> >>>>> 2. If it is possible, how do I do it?
> >>>>>   
> >>>>>       
> >>>> I have a hunch that I know what your
> problem is.
> >>>>
> >>>> You said that your pass is getting
> registered
> >> twice.  Are
> >>>> you sure that 
> >>>> your RegisterPass declaration is only
> being called
> >> once?  A
> >>>> common error 
> >>>> is to put the RegisterPass<MyPass>
> Foo
> >> variable
> >>>> inside a header file 
> >>>> that gets included by multiple .cpp files
> >> implementing your
> >>>> pass (I'm 
> >>>> assuming you've written a custom pass
> here). 
> >> This will
> >>>> cause your pass 
> >>>> to get registered multiple times, which
> will make
> >> the LLVM
> >>>> pass manager 
> >>>> unhappy.
> >>>>
> >>>> I believe this is because the
> RegisterPass<>
> >>>> constructor does pass 
> >>>> registration, so if it's declared
> multiple
> >> times, it
> >>>> registers the pass 
> >>>> multiple times.
> >>>>
> >>>> To fix it, put
> RegisterPass<YourPassName>
> >> inside one
> >>>> of the .cpp files 
> >>>> implementing your pass.
> >>>>
> >>>> Regarding your more specific questions, I
> suspect
> >> that EE
> >>>> can be used 
> >>>> with the Pass Manager to run optimization
> passes,
> >> but
> >>>> that's just a 
> >>>> guess on my part; I have never done it
> myself.  I
> >> suspect
> >>>> the issue is 
> >>>> just getting the right libraries listed in
> >> LINK_COMPONENTS
> >>>> and making 
> >>>> sure your pass isn't registered twice.
> >>>>
> >>>> Please let us know if the RegisterPass
> thing is
> >> the problem
> >>>> and whether 
> >>>> the solution above fixes it.
> >>>>
> >>>> Regards,
> >>>>
> >>>> -- John T.
> >>>>
> >>>>
> >>>>     
> >>>>> Please help me out here!
> >>>>> Thanks,
> >>>>> Bhavani
> >>>>>
> >>>>>
> >>>>>
> >>>>>       
> >>>>>
> >> _______________________________________________
> >>>>> 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 list
> > LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
> >


      



More information about the llvm-dev mailing list