Owen Anderson
2010-Oct-08 18:29 UTC
[LLVMdev] MAJOR API CHANGE: Pass initialization without static constructors
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. 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. * 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
Cyrille Berger Skott
2010-Oct-11 08:50 UTC
[LLVMdev] MAJOR API CHANGE: Pass initialization without static constructors
On Friday 08 October 2010, Owen Anderson wrote:> 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.Can we have a code example of how to do that ? -- Cyrille Berger Skott -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20101011/8e035d85/attachment.html>
Possibly Parallel Threads
- [LLVMdev] Fwd: Re: 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