Call Graph Analysis and function cloning

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

Call Graph Analysis and function cloning

Alireza.Moshtaghi
I need to perform call graph analysis (after all modules are merged) to
find which function calls which, and depending on the attributes that
each function has and what functions call it, I may need to clone it and
modify some of calls to that function to call the cloned function.

Currently we are doing this in few acrobatic moves that span from an
llvm-ld pass (to do call graph analysis) all the way to AsmPrinter (to
clone the function) and eventually our in-house linker (to check for
some irregularities). But I don't like it at all and I'm sure we will
run into problems later. So I would like to see if anybody has a better
answer for us.

I guess the most important question is how best (if possible) can I
clone a function before or during codegen.
Currently we are cloning the function in AsmPrinter but it does not look
good to me.

Any thoughts?

Alireza Moshtaghi
Senior Software Engineer
Development Systems, Microchip Technology

_______________________________________________
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: Call Graph Analysis and function cloning

Nick Lewycky
[hidden email] wrote:

> I need to perform call graph analysis (after all modules are merged) to
> find which function calls which, and depending on the attributes that
> each function has and what functions call it, I may need to clone it and
> modify some of calls to that function to call the cloned function.
>
> Currently we are doing this in few acrobatic moves that span from an
> llvm-ld pass (to do call graph analysis) all the way to AsmPrinter (to
> clone the function) and eventually our in-house linker (to check for
> some irregularities). But I don't like it at all and I'm sure we will
> run into problems later. So I would like to see if anybody has a better
> answer for us.
>
> I guess the most important question is how best (if possible) can I
> clone a function before or during codegen.

#include "llvm/Transforms/Utils/Cloning.h"
DenseMap<const Value *, Value *> ValueMap;
Function *NewF = llvm::CloneFunction(F, ValueMap);

Nick

> Currently we are cloning the function in AsmPrinter but it does not look
> good to me.
>
> Any thoughts?
>
> Alireza Moshtaghi
> Senior Software Engineer
> Development Systems, Microchip Technology
>
> _______________________________________________
> 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
Reply | Threaded
Open this post in threaded view
|

Re: Call Graph Analysis and function cloning

Jim Grosbach
In reply to this post by Alireza.Moshtaghi
Hi Ali,

I assume this is primarily for interrupt function handling? If so, I  
have a few ideas to bounce your direction if you're interested.

-j


On Aug 6, 2009, at 3:32 PM, [hidden email] wrote:

> I need to perform call graph analysis (after all modules are merged)  
> to
> find which function calls which, and depending on the attributes that
> each function has and what functions call it, I may need to clone it  
> and
> modify some of calls to that function to call the cloned function.
>
> Currently we are doing this in few acrobatic moves that span from an
> llvm-ld pass (to do call graph analysis) all the way to AsmPrinter (to
> clone the function) and eventually our in-house linker (to check for
> some irregularities). But I don't like it at all and I'm sure we will
> run into problems later. So I would like to see if anybody has a  
> better
> answer for us.
>
> I guess the most important question is how best (if possible) can I
> clone a function before or during codegen.
> Currently we are cloning the function in AsmPrinter but it does not  
> look
> good to me.
>
> Any thoughts?
>
> Alireza Moshtaghi
> Senior Software Engineer
> Development Systems, Microchip Technology
>
> _______________________________________________
> 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
Reply | Threaded
Open this post in threaded view
|

Re: Call Graph Analysis and function cloning

Alireza.Moshtaghi
Hi Jim,
Yes these are for interrupt handling. I have always learned from you and
of course would like to know about your input.

Thanks
Ali

> -----Original Message-----
> From: Jim Grosbach [mailto:[hidden email]]
> Sent: Friday, August 07, 2009 11:01 AM
> To: LLVM Developers Mailing List
> Cc: Alireza Moshtaghi - C13012
> Subject: Re: [LLVMdev] Call Graph Analysis and function cloning
>
> Hi Ali,
>
> I assume this is primarily for interrupt function handling? If so, I
> have a few ideas to bounce your direction if you're interested.
>
> -j
>
>
> On Aug 6, 2009, at 3:32 PM, [hidden email] wrote:
>
> > I need to perform call graph analysis (after all modules are merged)
> > to
> > find which function calls which, and depending on the attributes
that
> > each function has and what functions call it, I may need to clone it
> > and
> > modify some of calls to that function to call the cloned function.
> >
> > Currently we are doing this in few acrobatic moves that span from an
> > llvm-ld pass (to do call graph analysis) all the way to AsmPrinter
(to
> > clone the function) and eventually our in-house linker (to check for
> > some irregularities). But I don't like it at all and I'm sure we
will

> > run into problems later. So I would like to see if anybody has a
> > better
> > answer for us.
> >
> > I guess the most important question is how best (if possible) can I
> > clone a function before or during codegen.
> > Currently we are cloning the function in AsmPrinter but it does not
> > look
> > good to me.
> >
> > Any thoughts?
> >
> > Alireza Moshtaghi
> > Senior Software Engineer
> > Development Systems, Microchip Technology
> >
> > _______________________________________________
> > 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