From: | Martin Ward <martin@gkc.org.uk> |
Newsgroups: | comp.compilers |
Date: | Wed, 12 Jan 2011 12:31:39 +0000 |
Organization: | Compilers Central |
References: | 11-01-025 11-01-033 |
Keywords: | history |
Posted-Date: | 13 Jan 2011 00:10:23 EST |
On Monday 10 Jan 2011 at 18:23, compilers@is-not-my.name wrote:
> Because industry listened to academics, and they shouldn't have,
> ever. ...
> Remember the good old days when there was no conditional loop? Either
> you checked a condition and did a GO TO or you didn't have a
> loop. Life was good and simple. And yes, I still prefer my source code
> in all caps.
Suppose you are reading some code from the "good old days"
and you encounter a GO TO. Is there a loop or not?
First, you need to find the label that is the target of the GO TO:
if it is before the GO TO, then you have a loop, right?
Well, not necessarily. Only if there exists a control flow
path from the label back to the GO TO. Similarly, a forward GO TO
might still be a loop if there is a path back to the GO TO
from the label.
Suppose you have found out that there *is* a loop involved.
Now you want to know which statements are in the loop body
and which are not. To do that you need to construct the control
flow graph, find the dominator tree, the loop header nodes,
find all the nodes dominated by the loop header...
But that involves listening to those pesky academics!
--
Martin
STRL Reader in Software Engineering and Royal Society Industry Fellow
martin@gkc.org.uk http://www.cse.dmu.ac.uk/~mward/ Erdos number: 4
G.K.Chesterton web site: http://www.cse.dmu.ac.uk/~mward/gkc/
Mirrors: http://www.gkc.org.uk and http://www.gkc.org.uk/gkc
[Hey, it wasn't all academics. Some of it was IBM. But I take your
point. -John]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.