John Criswell
2010-Oct-08 20:10 UTC
[LLVMdev] Fwd: Re: MAJOR API CHANGE: Pass initialization without static constructors
Forgot to reply to the list. -- John T. -------- Original Message -------- Subject: Re: [LLVMdev] MAJOR API CHANGE: Pass initialization without static constructors Date: Fri, 8 Oct 2010 15:05:21 -0500 From: John Criswell <criswell at illinois.edu> To: Owen Anderson <resistor at mac.com> On 10/8/10 1:29 PM, Owen Anderson wrote:> Hello fellow LLVM-ers, > > As those of you who follow llvm-commits have probably noticed, I've been hard at work reworking our pass infrastructure to perform pass initialization/registration without static constructors. This is a boon for clients of the LLVM libraries, as they can now control when and if initialization occurs, as opposed to being forced to incur the initialization cost at startup, negatively impacting their startup times. > > The new-style solution consists of an llvm::initializeMyPass method for every pass.What is this method of our passes supposed to do? Is there a default implementation in the Pass class?> These initialization routines must be invoked before the PassManager will be able to resolve pipelines involving your pass. For convenience, LLVM now exposes per-library batch initialization routines, i.e. initializeScalarOpts(), which initialize all the passes within a given library in a single go.From an ease of programming perspective, this solution is not ideal as what we had before. Each time I link in a new library into my program, I have to go find the method that initializes all of the passes and remember to call it from my tool. Could you devise something better? For example, could you extend PassManager with a method that calls all of the passes's initialization methods? In other words, could you easily support something like: PassManager.add (Pass1); PassManager.add (Pass2); ... PassManager.add (PassN); PassManager.initializeAllPasses (); PassManager.run(); ... or could the PassManager::add() method automatically initialize the pass? Other possibilities may exists which are better as well; these are just the first two I've thought of. -- John T.> > > * WHAT THIS MEANS FOR LLVM USERS > > Users of LLVM will need to add explicit calls to the initialization routines to their programs. The trivial solution is to perform initialization at the beginning of main(), and to call the batch initialization routines for every LLVM library you link against. Clients interested in improving launch time and/or minimizing unnecessary linkage can defer initialization until it is needs, and/or only call the initialization routines for the individual passes that they depend on. > > Dynamically loaded plugins containing passes will continue to use the old-style style initialization scheme, and thus will continue to incur the cost of static constructors. Don't use them if you don't want static constructors. > > * WHAT THIS MEANS FOR LLVM DEVELOPERS > > I have already done this work for all passes already in the LLVM tree, but developers need to be aware for future work: > > You MUST use the new-style INITIALIZE_PASS, INITIALIZE_AG_PASS, and INITIALIZE_ANALYSIS_GROUP macros in place of the old-style RegisterPass<> templates. These macros will create an initializeMyPass() method, which you *MUST* declare in InitializePasses.h, and which you must add to your library's batch initialization method. > > --Owen Anderson > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20101008/ff86b5d6/attachment.html>
Reasonably Related Threads
- [LLVMdev] MAJOR API CHANGE: Pass initialization without static constructors
- [LLVMdev] MAJOR API CHANGE: Pass initialization without static constructors
- [LLVMdev] MAJOR API CHANGE: Pass initialization without static constructors
- [LLVMdev] MAJOR API CHANGE: Pass initialization without static constructors
- [LLVMdev] MAJOR API CHANGE: Pass initialization without static constructors