[LLVMdev] Preserving Analysis in ALL Passes
devang.patel at gmail.com
Tue Sep 22 09:31:41 PDT 2009
On Tue, Sep 22, 2009 at 9:16 AM, Andreas Neustifter
<astifter-llvm at gmx.at> wrote:
> I'm fighting with this quite some time now: Is there a way to mark an
> Analysis (in my case ProfileInfo) as perserved by _all_ passes?
> I have tried to add ProfileInfo directly in Pass.h:getAnalysisUsage()
> but that produces nasty circular library dependecies.
> I also tried to simply store a pointer to the ProfileInfo in Module but
> then the PassManager gets confused resulting in double freed memory.
> The only thing that helps is adding addPreserved<ProfileInfo>() to each
> pass, but thats quite tedious to do...
If a pass does not know that it is preserving XYZ then it is likely
that it is not preserving XYZ. LLVM Pass Manager explicitly expects
each pass to state what it preserves. Anything that is not explicitly
listed is considered dirtied.
> Any suggestions?
ImmutablePass is always preserved, so use it if it suites your needs.
Adding addPreserved<ProfileInfo>() to each pass may turn out to be
easier and cleaner solution for now.
However, if you are ready to modify PassManager internals, then you can
- Add additional parameter to registration mechanism to register
certain passes as AlwaysPreserved passes. (See how preservesCFG marker
- Update each pass manager to check AlwaysPreserved pass marker while
collecting list of preserved passes.
More information about the llvm-dev