[llvm-dev] possible inconsistency in PassManagerInternal.h
Fedor Sergeev via llvm-dev
llvm-dev at lists.llvm.org
Sun Sep 2 16:06:52 PDT 2018
You dont need to operate with classes defined in PassManagerInternal.h
They are, well, internal.
Unless you want to hack into the details of PassManager implementation
all you need
is to write a pass/analysis - which means implementing corresponding
::run() method - and register
it with the PassBuilder one way or another.
There are plenty of real examples of how you can write a pass in llvm
source tree.
Also there was a recent blog post mentioned on this list with an
introduction to new pass manager.
On 09/02/2018 11:22 PM, De Azevedo Piovezan, Felipe via llvm-dev wrote:
>
> Hello,
>
> (fairly new around here, apologies if the question has an obvious answer)
>
> I’ve been studying the structure of the new PassManager in the hopes
> of using it soon. After watching a couple of talks (Chandler /
> Sergeev), I decided to start with the Concept/Model classes in
> PassManagerInternal.h
>
> While I could make sense of almost everything there, two details
> caught my attention:
>
> 1- The PassConcept abstract class has a function `run = 0;` which
> returns an object of type `PreservedAnalysis`. Such object is
> forward-declared in this header, but it is defined in PassManager.h
> This is the only place in the file where we reference this class.
>
> However, right after, we define the PassModel class which derives from
> PassConcept, and one of its template parameters is a typename
> `PreservedAnalysisT`. The implementation of the `run` method uses the
> keyword override and it returns an object of type `PreservedAnalysisT`.
>
> This should raise a warning if PreservedAnalysisT !=
> PreservedAnalysis. Is this intentional? My naive intuition is that
> we should have removed PreservedAnalysisT from the template and used
> PreservedAnalysis. However, everywhere else in the file
> PreservedAnalysisT is used as template parameter.
>
> Am I missing something obvious?
>
PassModel is a generic template helper used deep inside PassManager
template.
You should neither be modifying anything in it nor using it directly.
And yes - PreservedAnalyses is the type that your Pass' run() method
should return.
> 2- A similar issue arises when using AnalysisManager.
>
> Both PassConcept and PassModel have a template typename
> `AnalysisManagerT`.
>
> However, AnalysisPassConcept and AnalysisPassModel have no such
> template parameter; instead, they use the forward-declared
> AnalysisManager type, defined in PassManager.h
>
> Again, is there a particular reason for this apparent inconsistency?
>
Again, it is not an inconsistency, just an implementation detail.
Ignore it and jump straight to using various AnalysisManagers defined in
PassManager.h/LoopPassManager.h etc.
regards,
Fedor.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180903/f3e5ce0f/attachment.html>
More information about the llvm-dev
mailing list