Adding structures in a loop pass

Hello,
     I wanted to do some speculative execution on a loop for which I
require some data storage structure for book keeping. The exact
structure of this storage buffer can only be determined after loop
analysis. Is there a clean way to add this new structure to the
module. Since this structure is to be used for each loop iteration I
do not want to allocate it inside the loop.

    A second alternative could be I run a module pass and go through
the loop inside that. Is there a way to call the loop pass from inside
the module pass or obtain information about the loops present inside
the module and individually call the loop pass on them.

Thanks in Advance,

Kshitiz,

Your loop pass should be able to manage this extra information. See
various loop transformations implementation, for example LoopRotation
maintains LoopHeaderInfo.

Devang,
Let me reframe my question.I require to keep this extra information as
a structure so as to pass it around to other functions which require
it. Specifically I am working on CellBE and wish to DMA this
information to the SPEs The way of adding the information by PHI nodes
will not suffise since the information may be very large in some cases
which will need to be transfered by a DMA rather than by parameter
passing.

From what I know it is not allowed to modify anything outside the
loop's scope in a loop pass. A runonFunction method will run on
functions and probably able to add this new struct type to the module.
Can you provide me pointers towards obtaining loops inside
runOnFunction method?

Thanks,
Kshitiz

Hi Kshitiz,

Devang,
Let me reframe my question.I require to keep this extra information as
a structure so as to pass it around to other functions which require
it. Specifically I am working on CellBE and wish to DMA this
information to the SPEs The way of adding the information by PHI nodes
will not suffise since the information may be very large in some cases
which will need to be transfered by a DMA rather than by parameter
passing.

In that case, you want to write an analysis pass that collect this
info which is used by another pass.

From what I know it is not allowed to modify anything outside the
loop's scope in a loop pass. A runonFunction method will run on
functions and probably able to add this new struct type to the module.
Can you provide me pointers towards obtaining loops inside
runOnFunction method?

see LPPassManager::runOnFunction(Function &F) in LoopPass.cpp