Sorry, it is my fault to cause the problem, I will take back the mail.
FWIW, I like to shared some experiences on this problem.
What to do:
I want to insert a control-block before every outermost loop. My current
solution is: 1) find each outermost loop in some function; 2) find the loop
header with Loop->getHeader() APIs, and then insert the controller block
before the header block of current loop.
In the first, I don't know we can get the outermost loop list from
LoopInfo, so, I iterate over the BB of function and usr LI->getLoopFor(BB),
to get the Loop object CurLoop, then to do something else...., And I made a
mistake in this process.
Now, I find we can get Loop object from LoopInfo like the follow example
LoopInfo::iterator LIB = LI->begin;
*LIB points to the outer most loop of the function. It is done now.
Sorry for bothering all of you!
Eric Lu
On Tue, May 21, 2013 at 3:41 PM, Eric Lu <eirc.lew at gmail.com> wrote:
> Hello,
> I want to insert a control-block before every outermost loop. My current
> solution is: 1) find each outermost loop in some function; 2) find the loop
> header with Loop->getHeader() APIs, and then insert the controller block
> before the header block of current loop.
>
> But I encounters problems when there multi subsequent loops in the
> following example, where there is no code between loops:
>
> for( i = 0 ; i < N; i++){
> arrayA[i] = i + 1;
> }
>
>
> for( j = 0 ; j < N; j++){
> arrayA[j] = j + 1;
> }
>
>
> for( k = 0 ; k < N; k++){
> arrayC[k] = k + 1;
> }
>
> In this case, these loops have the same header block, so the previous
> method failed. And it seems the method of block_begin() returns the same
> value as getHeader().
> Are there some other methods to implement this ?
>
> Thanks!
>
> Eric
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20130522/d2023bd7/attachment.html>