Devang Patel wrote:> On Sun, Jul 12, 2009 at 2:09 PM, shu<shuguang.feng at gmail.com> wrote: > >> Is there a beginner's tutorial/documentation on how to write passes >> for the llc tool? I've managed to write some simple analysis passes >> for the opt tool but can't figure out how to do the same for llc. >> What is the proper way to integrate a new MachineFunction pass with >> llc? Is there a way to register passes and selectively enable them on >> the command line (as with opt) or do I need to hard code it into >> llc.cpp? >> >> I would like to be able to write a pass that looks at MachineFunctions >> and inserts instructions right before register allocation (but after >> all other optimization/instruction selection passes). Any direction/ >> advice would be of great help. Thanks! >> > > llc uses Target.addPassesToEmit* interface to add passes. You can > insert your pass at appropriate place here. > > - > Devang > >One related question. Can we write CallGraphSCCPass in llc? - Sanjiv
Hi Sanjiv,> Can we write CallGraphSCCPass in llc?not really. The code generator should do everything one function at a time. This allows you to materialize and codegen functions on demand, or codegen functions one at a time, deleting function bodies after they are codegened. So while you probably could calculate and make use of the callgraph, it is against the codegen philosophy and may not work properly in all cases. Ciao, Duncan.
On Wed, 2009-07-15 at 11:10 +0200, Duncan Sands wrote:> Hi Sanjiv, > > > Can we write CallGraphSCCPass in llc? > > not really. The code generator should do everything one function > at a time. This allows you to materialize and codegen functions on > demand, or codegen functions one at a time, deleting function bodies > after they are codegened. So while you probably could calculate and > make use of the callgraph, it is against the codegen philosophy and > may not work properly in all cases. > > Ciao, > > Duncan.Thanks Duncan for explaining this. The basic problem that I was trying to solve is to find all the functions called from a top-level interrupt routine in the whole program. Looks like llvm-ld is the best place to get this kind of info. Thx, - Sanjiv> _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev