Running both Function and Loop passes together

Hi

I want to write a LLVM pass that transforms loops only if they belong to certain special functions.
Right now I have a pass that can transform loops as I intend, but I do not know how to check if the loop is actually contained in one of the special functions.
Is there a way to identify the function to which a particular loop belongs ?

I am not sure if my pass should implement both runOnLoop and runOnFunction methods or not.
I tried implementing a pass that subclasses both Function and Loop Pass, but that didn’t seem to work.

Any suggestions on the best way to implement such a pass will be extremely helpful.

Thanks!
Malveeka

Hi Malveeka,

I want to write a LLVM pass that transforms loops only if they belong to certain
special functions.
Right now I have a pass that can transform loops as I intend, but I do not know
how to check if the loop is actually contained in one of the special functions.
Is there a way to identify the function to which a particular loop belongs ?

if BB is a basic block (eg: one belonging to the loop) then BB->getParent() will
return the enclosing function.

Ciao, Duncan.