Date: Fri, 24 Aug 2007 22:23:39 -0700
From: Chris Lattner <sabre@nondot.org>
Subject: Re: [LLVMdev] constructing 'for' statement from LLVM bitcode
To: LLVM Developers Mailing List <llvmdev@cs.uiuc.edu>
Do you have any idea on how I can construct 'for' more systemically
with this CDG info from LLVM bitcode?
I strongly suggest looking at the Muchnick book: http://
www.amazon.com/Advanced-Compiler-Design-Implementation-Muchnick/dp/
1558603204
It has a section on "structural analysis" that you will find useful.
Why do you want "for statements"?
Thank you for this info, Chris.
I'm doing this 'cause I'm making a backend for a virtual machine assembly has an instruction which is very similar to 'for' statement.
I know this seems quite strange for that machine instruction looks quite high-level.
Furthermore, it doesn't have instructions such as 'br' in LLVM so this is why I have to re-construct 'for' statement for the assembly from LLVM bitcode. (I must not use 'goto' in the high-level source code, either. :-/)
Thanks,
SJL
It has a section on "structural analysis" that you will find useful.
Why do you want "for statements"?
Thank you for this info, Chris.
I'm doing this 'cause I'm making a backend for a virtual machine assembly has an instruction which is very similar to 'for' statement.
I know this seems quite strange for that machine instruction looks quite high-level.
Furthermore, it doesn't have instructions such as 'br' in LLVM so this is why I have to re-construct 'for' statement for the assembly from LLVM bitcode. (I must not use 'goto' in the high-level source code, either. :-/)
Ok. Note that LLVM can represent irreducible loops. You can handle this through code duplication.
-Chris
Seung,
Ok. Note that LLVM can represent irreducible loops. You can handle
this through code duplication.
-Chris
If you are willing to invest more effort into a more complicated analysis,
in many cases you can even avoid code duplication. See this paper for
details:
@inproceedings{erosa94taming,
author = {Ana M. Erosa and
Laurie J. Hendren},
title = {Taming Control Flow: A Structured Approach to Eliminating
Goto Statements.},
booktitle = {ICCL},
year = {1994},
pages = {229--240},
}
Cheers,
Seung,
> Ok. Note that LLVM can represent irreducible loops. You can handle
> this through code duplication.
> -Chris
If you are willing to invest more effort into a more complicated analysis,
in many cases you can even avoid code duplication. See this paper for
details:
We implemented this in GCC early on in the days of GIMPLE, and while
theoretically it removes code duplication, in practice it made the
code take significantly more space and run slower. 
That's because of the new conditions, and new control variables. As
this technique transforms control flow dependences to data deps, it
depends on how many cfg edges you are redirecting via temp variables.
A nice example is when the transformed jump is from a loop to another
loop: the number of checks to the control variable is the depth from
the first loop to the common parent plus the depth for the second loop
to the parent.