[LLVMdev] Identify Loops from within FunctionPass, or possible to intermix different types of Passes?

Chuck Zhao czhao at eecg.toronto.edu
Thu Jan 6 09:21:17 PST 2011


LLVMers,

I have a traversal plan which needs to visit certain types of Functions. 
For each instruction in such functions, I will need to know:
1. is it located inside a loop
2. if yes, what level of loop nest it is currently in.

So on the highest level, it should be a FunctionPass. However, in order 
to identify loops and loop-nest levels, it should also be a LoopPass.

Is there a reasonably simple way to identify loop(s) within a function 
under FunctionPass?

(Any existing LLVM code that I can take a look?)

OR

Is it possible to intermix different types of LLVM Passes?

E.g.

class MyPass: public FunctionPass, public LoopPass{
   ...
public:
   bool runOnFunction(...);
   bool runOnLoop(...);
   ...
};

Does this make any sense?
I haven't seem to find any existing LLVM pass under such uses.


Thank you very much

Chuck

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110106/b003904a/attachment.html>


More information about the llvm-dev mailing list