[llvm-dev] How can I use llvm::LoopInfo in the runOnModule method?

David Greene via llvm-dev llvm-dev at lists.llvm.org
Wed Apr 3 11:33:04 PDT 2019


Florian Hahn <florian_hahn at apple.com> writes:

>  On Apr 3, 2019, at 17:40, David Greene via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>
>  I don't think one can reliably get a Function analysis pass from within
>  a ModulePass using the legacy pass manager.  You have to manually
>  construct the pass yourself.
>
> That’s strange. AFAIK IPSCCP does exactly that for the DT analysis, see getAnalysis in 
>    https://github.com/llvm/llvm-project/blob/master/llvm/lib/Transforms/IPO/SCCP.cpp#L53

Yes, I know.  That's what I modeled my solution after.  And it worked
for a bunch of codes I ran it on.  Until it didn't.

I think IPSCCP is broken because the on-the-fly pass manager stuff is
broken.

> It does not seem like the legacy pass manager is able to preserve
> Function analyses from Module passes, whereas the new pass manager
> can, however.

It's not about preserving analyses.  The analyses are not safely
available within the ModulePass itself.  They get deleted sometime
during the sequence of calls to getAnalysis.

                      -David


More information about the llvm-dev mailing list