[llvm-dev] Let CallGraphSCCPass Use Function-Level Analysis

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[llvm-dev] Let CallGraphSCCPass Use Function-Level Analysis

Jeremy Morse via llvm-dev

Dear all,

 

I would like to use the PostDominatorTree in ArgPromotion. I did not find an example of how to use function level analysis inside CallGraphSCCPass. I tried to follow an example of how to use function-level pass in a module pass, but I hit “llvm_unreachable” in PMDataManager::addLowerLevelRequiredPass.

 

What would be a proper way to make PostDominatorTree available in ArgPromotion?

 

Thanks in advance,

 

Mikhail


_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Let CallGraphSCCPass Use Function-Level Analysis

Jeremy Morse via llvm-dev
Hello! The new pass manager provides analysis proxies from one IR unit
type to another. These are specializations of
'llvm::InnerAnalysisManagerProxy'. For example,
'llvm::FunctionAnalysisManagerModuleProxy' allows you to access
function analyses from within module passes.

In your case, it sounds like you'd want to use
'llvm::FunctionAnalysisManagerCGSCCProxy', which allows you to access
function analyses from within an CGSCC pass. Here's an example of
using it:

```
class MyCGSCCPass : public llvm::PassInfoMixin<MyCGSCCPass> {
public:
  llvm::PreservedAnalyses run(llvm::LazyCallGraph::SCC &C,
                              llvm::CGSCCAnalysisManager &AM,
                              llvm::LazyCallGraph &CG,
                              llvm::CGSCCUpdateResult &UR) {
    llvm::FunctionAnalysisManager &FAM =
        AM.getResult<llvm::FunctionAnalysisManagerCGSCCProxy>(C, CG)
            .getManager();
    for (llvm::LazyCallGraph::Node &N : C) {
      llvm::Function &F = N.getFunction();
      llvm::PostDominatorTree &PDT =
          FAM.getResult<llvm::PostDominatorTreeAnalysis>(F);
      PDT.print(llvm::outs());
    }
    return llvm::PreservedAnalyses::none();
  }
};
```

Here's a full example of the above:
https://gist.github.com/modocache/d5804ba567476e32cad1fd0850363532

I was just reading through this part of the codebase, so I'm a little
familiar with it now. Anyway, hope this helps!

- Brian Gesiak

On Tue, Jan 7, 2020 at 8:13 AM Mikhail Gudim via llvm-dev
<[hidden email]> wrote:

>
> Dear all,
>
>
>
> I would like to use the PostDominatorTree in ArgPromotion. I did not find an example of how to use function level analysis inside CallGraphSCCPass. I tried to follow an example of how to use function-level pass in a module pass, but I hit “llvm_unreachable” in PMDataManager::addLowerLevelRequiredPass.
>
>
>
> What would be a proper way to make PostDominatorTree available in ArgPromotion?
>
>
>
> Thanks in advance,
>
>
>
> Mikhail
>
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Let CallGraphSCCPass Use Function-Level Analysis

Jeremy Morse via llvm-dev
Hi Mikhail,

As Brian noted, stuff like this works better in the new pass manager.

Even in the old pass manager I thought it should work though.
Did you initialize the pass, via
 `INITIALIZE_PASS_DEPENDENCY(PostDominatorTreeWrapperPass)`?
Did you require it, via
` AU.addRequired<PostDominatorTreeWrapperPass>();`?

Btw. May I ask what you are planning to do?

Cheers,
  Johannes


On 01/07, Brian Gesiak via llvm-dev wrote:

> Hello! The new pass manager provides analysis proxies from one IR unit
> type to another. These are specializations of
> 'llvm::InnerAnalysisManagerProxy'. For example,
> 'llvm::FunctionAnalysisManagerModuleProxy' allows you to access
> function analyses from within module passes.
>
> In your case, it sounds like you'd want to use
> 'llvm::FunctionAnalysisManagerCGSCCProxy', which allows you to access
> function analyses from within an CGSCC pass. Here's an example of
> using it:
>
> ```
> class MyCGSCCPass : public llvm::PassInfoMixin<MyCGSCCPass> {
> public:
>   llvm::PreservedAnalyses run(llvm::LazyCallGraph::SCC &C,
>                               llvm::CGSCCAnalysisManager &AM,
>                               llvm::LazyCallGraph &CG,
>                               llvm::CGSCCUpdateResult &UR) {
>     llvm::FunctionAnalysisManager &FAM =
>         AM.getResult<llvm::FunctionAnalysisManagerCGSCCProxy>(C, CG)
>             .getManager();
>     for (llvm::LazyCallGraph::Node &N : C) {
>       llvm::Function &F = N.getFunction();
>       llvm::PostDominatorTree &PDT =
>           FAM.getResult<llvm::PostDominatorTreeAnalysis>(F);
>       PDT.print(llvm::outs());
>     }
>     return llvm::PreservedAnalyses::none();
>   }
> };
> ```
>
> Here's a full example of the above:
> https://gist.github.com/modocache/d5804ba567476e32cad1fd0850363532
>
> I was just reading through this part of the codebase, so I'm a little
> familiar with it now. Anyway, hope this helps!
>
> - Brian Gesiak
>
> On Tue, Jan 7, 2020 at 8:13 AM Mikhail Gudim via llvm-dev
> <[hidden email]> wrote:
> >
> > Dear all,
> >
> >
> >
> > I would like to use the PostDominatorTree in ArgPromotion. I did not find an example of how to use function level analysis inside CallGraphSCCPass. I tried to follow an example of how to use function-level pass in a module pass, but I hit “llvm_unreachable” in PMDataManager::addLowerLevelRequiredPass.
> >
> >
> >
> > What would be a proper way to make PostDominatorTree available in ArgPromotion?
> >
> >
> >
> > Thanks in advance,
> >
> >
> >
> > Mikhail
> >
> > _______________________________________________
> > LLVM Developers mailing list
> > [hidden email]
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
--

Johannes Doerfert
Researcher

Argonne National Laboratory
Lemont, IL 60439, USA

[hidden email]

_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

signature.asc (235 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Let CallGraphSCCPass Use Function-Level Analysis

Jeremy Morse via llvm-dev
Thanks Brian and Johannes for your replies.

    " As Brian noted, stuff like this works better in the new pass manager."

Yes, but I need it to work for the old pass manager.

        " Did you initialize the pass, via
     `INITIALIZE_PASS_DEPENDENCY(PostDominatorTreeWrapperPass)`?
     Did you require it, via
     ` AU.addRequired<PostDominatorTreeWrapperPass>();`"

Yes, I did.

    " Btw. May I ask what you are planning to do?"

I would like to iterate through all post-dominators of the entry block (instead of just the entry block) to find more opportunities for argument promotion:

https://reviews.llvm.org/D72382

Btw, it would be great if you could review / give some feedback on that patch.
-----Original Message-----
From: Doerfert, Johannes [mailto:[hidden email]]
Sent: Tuesday, January 07, 2020 12:19 PM
To: Brian Gesiak <[hidden email]>
Cc: Mikhail Gudim <[hidden email]>; [hidden email]
Subject: Re: [llvm-dev] Let CallGraphSCCPass Use Function-Level Analysis

Hi Mikhail,

As Brian noted, stuff like this works better in the new pass manager.

Even in the old pass manager I thought it should work though.
Did you initialize the pass, via
 `INITIALIZE_PASS_DEPENDENCY(PostDominatorTreeWrapperPass)`?
Did you require it, via
` AU.addRequired<PostDominatorTreeWrapperPass>();`?

Btw. May I ask what you are planning to do?

Cheers,
  Johannes


On 01/07, Brian Gesiak via llvm-dev wrote:

> Hello! The new pass manager provides analysis proxies from one IR unit
> type to another. These are specializations of
> 'llvm::InnerAnalysisManagerProxy'. For example,
> 'llvm::FunctionAnalysisManagerModuleProxy' allows you to access
> function analyses from within module passes.
>
> In your case, it sounds like you'd want to use
> 'llvm::FunctionAnalysisManagerCGSCCProxy', which allows you to access
> function analyses from within an CGSCC pass. Here's an example of
> using it:
>
> ```
> class MyCGSCCPass : public llvm::PassInfoMixin<MyCGSCCPass> {
> public:
>   llvm::PreservedAnalyses run(llvm::LazyCallGraph::SCC &C,
>                               llvm::CGSCCAnalysisManager &AM,
>                               llvm::LazyCallGraph &CG,
>                               llvm::CGSCCUpdateResult &UR) {
>     llvm::FunctionAnalysisManager &FAM =
>         AM.getResult<llvm::FunctionAnalysisManagerCGSCCProxy>(C, CG)
>             .getManager();
>     for (llvm::LazyCallGraph::Node &N : C) {
>       llvm::Function &F = N.getFunction();
>       llvm::PostDominatorTree &PDT =
>           FAM.getResult<llvm::PostDominatorTreeAnalysis>(F);
>       PDT.print(llvm::outs());
>     }
>     return llvm::PreservedAnalyses::none();
>   }
> };
> ```
>
> Here's a full example of the above:
> https://gist.github.com/modocache/d5804ba567476e32cad1fd0850363532
>
> I was just reading through this part of the codebase, so I'm a little
> familiar with it now. Anyway, hope this helps!
>
> - Brian Gesiak
>
> On Tue, Jan 7, 2020 at 8:13 AM Mikhail Gudim via llvm-dev
> <[hidden email]> wrote:
> >
> > Dear all,
> >
> >
> >
> > I would like to use the PostDominatorTree in ArgPromotion. I did not find an example of how to use function level analysis inside CallGraphSCCPass. I tried to follow an example of how to use function-level pass in a module pass, but I hit “llvm_unreachable” in PMDataManager::addLowerLevelRequiredPass.
> >
> >
> >
> > What would be a proper way to make PostDominatorTree available in ArgPromotion?
> >
> >
> >
> > Thanks in advance,
> >
> >
> >
> > Mikhail
> >
> > _______________________________________________
> > LLVM Developers mailing list
> > [hidden email]
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

--

Johannes Doerfert
Researcher

Argonne National Laboratory
Lemont, IL 60439, USA

[hidden email]
_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Let CallGraphSCCPass Use Function-Level Analysis

Jeremy Morse via llvm-dev
On 01/09, Mikhail Gudim wrote:

> Thanks Brian and Johannes for your replies.
>
>     " As Brian noted, stuff like this works better in the new pass manager."
>
> Yes, but I need it to work for the old pass manager.
>
> " Did you initialize the pass, via
>      `INITIALIZE_PASS_DEPENDENCY(PostDominatorTreeWrapperPass)`?
>      Did you require it, via
>      ` AU.addRequired<PostDominatorTreeWrapperPass>();`"
>
> Yes, I did.
Worst case, you could build the PostDominatorTree yourself in the pass.


>     " Btw. May I ask what you are planning to do?"
>
> I would like to iterate through all post-dominators of the entry block (instead of just the entry block) to find more opportunities for argument promotion:
>
> https://reviews.llvm.org/D72382
>
> Btw, it would be great if you could review / give some feedback on that patch.

Done.

_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

signature.asc (235 bytes) Download Attachment