[LLVMdev] Best way to require a pass from a dynamically loaded module?

Chris Lattner sabre at nondot.org
Tue Apr 19 09:46:18 PDT 2005


On Mon, 18 Apr 2005, Michael McCracken wrote:

> Hi, I have a situation where I built an analysis pass as a loadable
> module, but I'd like to require it from other passes, to make it
> available if it's been loaded.

Does this mean that the "other passes" are not part of the loadable 
module?

> Is there a clean way to do this, or am I stretching it too far?
> If there isn't a nice way, I'd be interested in discussion about what
> would be the least ugly hack just to get it working.

One thing you could use/abuse is the AnalysisGroup mechanism.  You could 
define an analysis group MyAG, with a default (empty) implementation.  The 
loadable module could implement another implementation of MyAG.  Other 
passes could use MyAG without knowing whether they are getting the default 
("empty") implementation or the loaded one.

Analysis groups are how the AliasAnalysis itf works for example.  The 
HowToWriteAPass guide should explain how it works,

-Chris

-- 
http://nondot.org/sabre/
http://llvm.cs.uiuc.edu/




More information about the llvm-dev mailing list