FunctionPass requiring SCCs

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

FunctionPass requiring SCCs

Ryan M. Lefever
I have a FunctionPass F that needs a list of all the SCCs for use in its
doFinalization() method.  Let's say I write a CallGraphSCCPass C that
creates an array of all SCCs.  Let C be required by F, and let F call
getAnalysis<C>() from its doFinalization() method.  Am I guaranteed that
C's runOnSCC() method will have executed on all SCCs before F's
doFinalization() method?  In other words, when F calls getAnalysis<C>()
from its doFinalization() method, am I guaranteed that C will have been
able to build the array of SCCs?  If not, how else might I structure things?

Regards,
Ryan

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: FunctionPass requiring SCCs

Domagoj Babic
Hi Ryan,

On 9/29/06, Ryan M. Lefever <[hidden email]> wrote:
> I have a FunctionPass F that needs a list of all the SCCs for use in its
> doFinalization() method.  Let's say I write a CallGraphSCCPass C that
> creates an array of all SCCs.  Let C be required by F, and let F call
> getAnalysis<C>() from its doFinalization() method.  Am I guaranteed that
> C's runOnSCC() method will have executed on all SCCs before F's
> doFinalization() method?  In other words, when F calls getAnalysis<C>()
> from its doFinalization() method, am I guaranteed that C will have been
> able to build the array of SCCs?  If not, how else might I structure things?

That should work. I've written such code, something like:
bool doFinalization(Module &M) {
  CallGraph &CG = getAnalysis<CallGraph>();
  for (scc_iterator<CallGraph*> SCCI = scc_begin(&CG),
    SCCE = scc_end(&CG); SCCI != SCCE; ++SCCI) {
    unsigned size = (*SCCI).size();
    for (unsigned i = 0; i < size; ++i) {
      Function *F = (*SCCI)[i]->getFunction();
      ......
    }
  }
  ....
}

Check out scc_* iterators. Also note that the call graph
is not aware of the indirect calls, so you will need to write your
own CG implementation if you need to handle function pointers
soundly.

Domagoj Babic
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: FunctionPass requiring SCCs

Vikram S. Adve-2

On Sep 29, 2006, at 2:05 PM, Domagoj Babic wrote:

>
> Check out scc_* iterators. Also note that the call graph
> is not aware of the indirect calls, so you will need to write your
> own CG implementation if you need to handle function pointers
> soundly.
>


Chris, is this true?  If so, it seems like a bad property for the  
CallGraphSCCPass framework.

--Vikram
http://www.cs.uiuc.edu/~vadve
http://llvm.cs.uiuc.edu/


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: FunctionPass requiring SCCs

Chris Lattner
On Fri, 29 Sep 2006, Vikram Adve wrote:
> On Sep 29, 2006, at 2:05 PM, Domagoj Babic wrote:
>> Check out scc_* iterators. Also note that the call graph
>> is not aware of the indirect calls, so you will need to write your
>> own CG implementation if you need to handle function pointers
>> soundly.
> Chris, is this true?  If so, it seems like a bad property for the
> CallGraphSCCPass framework.

This isn't true.  The *default* implementation of the callgraph interface
handles function pointers soundly, just non-aggressively: it assumes they
can point to any function.  Of course you can provide your own
implementation of the CallGraph interface, or use something more
aggressive (e.g. DSA).

If you're seeing cases this isn't happening, please file a bug.

-Chris

--
http://nondot.org/sabre/
http://llvm.org/
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: FunctionPass requiring SCCs

Domagoj Babic
Chris,

Thx for correcting me. I don't remember how I came to that conclusion.

Domagoj

On 9/29/06, Chris Lattner <[hidden email]> wrote:

> On Fri, 29 Sep 2006, Vikram Adve wrote:
> > On Sep 29, 2006, at 2:05 PM, Domagoj Babic wrote:
> >> Check out scc_* iterators. Also note that the call graph
> >> is not aware of the indirect calls, so you will need to write your
> >> own CG implementation if you need to handle function pointers
> >> soundly.
> > Chris, is this true?  If so, it seems like a bad property for the
> > CallGraphSCCPass framework.
>
> This isn't true.  The *default* implementation of the callgraph interface
> handles function pointers soundly, just non-aggressively: it assumes they
> can point to any function.  Of course you can provide your own
> implementation of the CallGraph interface, or use something more
> aggressive (e.g. DSA).
>
> If you're seeing cases this isn't happening, please file a bug.
>
> -Chris
>
> --
> http://nondot.org/sabre/
> http://llvm.org/
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev