Re: Squashing C Source (David Keppel)
17 Dec 90 02:42:14 GMT

          From comp.compilers

Related articles
Squashing C Source (H T Fallside) (1990-12-05)
Re: Squashing C Source (1990-12-11)
Re: Squashing C Source megatest! (1990-12-14)
Re: Squashing C Source (1990-12-17)
Re: Squashing C Source (H T Fallside) (1990-12-17)
Re: Squashing C Source (Lee Woodbury) (1990-12-17)
Re: Squashing C Source (1990-12-18)
| List of all articles for this month |

Newsgroups: comp.compilers
From: (David Keppel)
Keywords: optimize
Organization: University of Washington, Computer Science, Seattle
References: <> <14662@goofy.megatest.UUCP>
Date: 17 Dec 90 02:42:14 GMT

>>[I want to create one huge main()]

megatest! (Dave Jones) writes:
>[Why? It will certainly make the resulting object code slower.]
>[For example, call/return is an efficient way to save/restore
> registers; the program will be larger unless procedures have only
> one call site; a larger program is usually slower; you will have to
> reinvent procedure calls to handle recursion.]

Um, er, ah, well, uh...

I'm not the original author so I can't comment on why s/he wanted to do
it. It does seem to me, though, that you're imagining a particular
model for how things get expanded. I don't see any particular reason
why ANY of the problems mentioned above are ``problems''.

* Call/return as an efficient way to save/restore registers

The VAX and Tahoes are optimized to save and restore registers in
call/return, but also have an explict register save with mask
instruction that does the same thing without the overhead of setting up
the argument/frame pointer(s), etc. The 680x0 family has a similar

On many RISCy machines -- and on a number of CISCy machines -- register
save/restore is left almost entirely up to the programmer, the major
exceptions being CISCy machines that dedicate the program counter and
the stack pointer.

* The program will be larger unless procedures have only one call site.

That's assuming that you have a function inlined everywhere that they
appear. An alternative is to take each function |x| and produce a
label |x| and a set of ``calling conventions'' for transferring control
to that label. You do wind up reinventing the procedure call, it is
true, but you also wind up with equivalent-size code.

* A larger program will generally be slower

That depends in great detail on things like caching behavior. Strictly
inling long squences is almost always a lose, but shorter sequences can
profitably be replicated at a substantial increase in ojbect code size
if, say, the larger code improves prefetching.

* You have to reinvent procedure calls to handle recursion.

Excluding the case of tail calling, yes, you do have to reinvent
procedure calls. However, you might get more freedom about designing
custom calling conventions.

In summary, aggressive compilers such as the MIPS compiler generally
try to create one large procedure out of a program. They generally
don't inline recursive calls unless they are tail-recursive. The major
difference is that they reserve ``squashing everything in to one big
function'' for e.g., link time.

Yeah, well, I'd like to squash C source, too, but for my needs it's the
best programming language I have avaialable.

;-D on ( But working on it anyway ) Pardo

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.