dependent passes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

dependent passes

Ryan M. Lefever
I am trying to create two passes X and Y, in which pass X depends on
pass Y.  After attempting this several times it appears that pass Y must
be in the llvm namespace.  Whenever it was not in the llvm namespace,
"opt -load" would complain about undefined symbols when I called
getAnalysis<>(). Am I correct that the pass that is depended on must be
in the llvm namespace?  If so, that was not clear in the documentation
regarding writing an LLVM pass.

Thanks,
Ryan
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: dependent passes

Devang Patel

On Sep 26, 2006, at 5:49 PM, Ryan M. Lefever wrote:

> I am trying to create two passes X and Y, in which pass X depends on
> pass Y.  After attempting this several times it appears that pass Y  
> must
> be in the llvm namespace.  Whenever it was not in the llvm namespace,
> "opt -load" would complain about undefined symbols when I called
> getAnalysis<>(). Am I correct that the pass that is depended on must  
> be
> in the llvm namespace?  If so, that was not clear in the documentation
> regarding writing an LLVM pass.

http://llvm.org/docs/WritingAnLLVMPass.html says,

-----
Basic code required
Now that we have a way to compile our new pass, we just have to write  
it. Start out with:

#include "llvm/Pass.h"
#include "llvm/Function.h"
Which are needed because we are writing a Pass, and we are operating  
on Function's.

Next we have:

using namespace llvm;
... which is required because the functions from the include files  
live in the llvm namespace.

----



-

Devang
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: dependent passes

Ryan M. Lefever
I think that we are talking about two different things.  I understand
that in order to use LLVM classes you must either qualify them with the
llvm namespace or use the statement "using namespace llvm;"  What I'm
saying is that it has been my experience that when a pass Y depends on
another pass X, i.e, Y is a required analysis of X, then Y must be
defined within the llvm namespace rather than in an anonymous namespace
as http://llvm.org/docs/WritingAnLLVMPass.html suggests it should be.
I'm wondering if that is correct, or if I'm missing something.

Regards,
Ryan


Devang Patel wrote:

> On Sep 26, 2006, at 5:49 PM, Ryan M. Lefever wrote:
>
>> I am trying to create two passes X and Y, in which pass X depends on
>> pass Y.  After attempting this several times it appears that pass Y  
>> must
>> be in the llvm namespace.  Whenever it was not in the llvm namespace,
>> "opt -load" would complain about undefined symbols when I called
>> getAnalysis<>(). Am I correct that the pass that is depended on must  
>> be
>> in the llvm namespace?  If so, that was not clear in the documentation
>> regarding writing an LLVM pass.
>
> http://llvm.org/docs/WritingAnLLVMPass.html says,
>
> -----
> Basic code required
> Now that we have a way to compile our new pass, we just have to write  
> it. Start out with:
>
> #include "llvm/Pass.h"
> #include "llvm/Function.h"
> Which are needed because we are writing a Pass, and we are operating  
> on Function's.
>
> Next we have:
>
> using namespace llvm;
> ... which is required because the functions from the include files  
> live in the llvm namespace.
>
> ----
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: dependent passes

Chris Lattner
On Wed, 27 Sep 2006, Ryan M. Lefever wrote:
> I think that we are talking about two different things.  I understand
> that in order to use LLVM classes you must either qualify them with the
> llvm namespace or use the statement "using namespace llvm;"  What I'm
> saying is that it has been my experience that when a pass Y depends on
> another pass X, i.e, Y is a required analysis of X, then Y must be
> defined within the llvm namespace rather than in an anonymous namespace
> as http://llvm.org/docs/WritingAnLLVMPass.html suggests it should be.
> I'm wondering if that is correct, or if I'm missing something.

If X depends on Y, and Y is defined in another file in an anonymous
namespace, there is no way for X to refer to Y.  This is how C++ anonymous
namespaces work, which doesn't have anything to do with passes.

I've used passes defined in other (non-anon) namespaces, and they seem to
work fine.  Can you elaborate on the problem you're seeing?

-Chris

--
http://nondot.org/sabre/
http://llvm.org/
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: dependent passes

Ryan M. Lefever
Thanks Chris.  The problem that I was seeing is that when Y is defined
in a separate file from X, in an anonymous namespace, X has no way to
refer to Y.  Everything was fixed when I gave a name to the namespace
that Y was defined in, and contrary to my previous post, that namespace
name does not necessarily need to be llvm.

Ryan

Chris Lattner wrote:

> On Wed, 27 Sep 2006, Ryan M. Lefever wrote:
>> I think that we are talking about two different things.  I understand
>> that in order to use LLVM classes you must either qualify them with the
>> llvm namespace or use the statement "using namespace llvm;"  What I'm
>> saying is that it has been my experience that when a pass Y depends on
>> another pass X, i.e, Y is a required analysis of X, then Y must be
>> defined within the llvm namespace rather than in an anonymous namespace
>> as http://llvm.org/docs/WritingAnLLVMPass.html suggests it should be.
>> I'm wondering if that is correct, or if I'm missing something.
>
> If X depends on Y, and Y is defined in another file in an anonymous
> namespace, there is no way for X to refer to Y.  This is how C++ anonymous
> namespaces work, which doesn't have anything to do with passes.
>
> I've used passes defined in other (non-anon) namespaces, and they seem to
> work fine.  Can you elaborate on the problem you're seeing?
>
> -Chris
>

--
Ryan M. Lefever  [http://www.ews.uiuc.edu/~lefever]

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev