Re: C struct Ordering Rules

bill@amber.ssd.csd.harris.com (Bill Leonard)
Tue, 1 Nov 1994 22:00:41 GMT

          From comp.compilers

Related articles
CProf cache profiling system available david@cs.wisc.edu (1994-10-13)
Re: C struct Ordering Rules (Re: Data Structure Reorganizing Optimizat bart@cs.uoregon.edu (1994-10-27)
Re: C struct Ordering Rules bart@cs.uoregon.edu (1994-10-31)
Re: C struct Ordering Rules bbpy969@server4.bell-atl.com (1994-10-31)
Re: C struct Ordering Rules bill@amber.ssd.csd.harris.com (1994-11-01)
Re: C struct Ordering Rules daniels@cse.ogi.edu (1994-11-01)
Re: C struct Ordering Rules meissner@osf.org (1994-11-01)
| List of all articles for this month |

Newsgroups: comp.arch,comp.compilers
From: bill@amber.ssd.csd.harris.com (Bill Leonard)
Keywords: C, design, optimize
Organization: Harris Computer Systems, Ft. Lauderdale FL
References: 94-10-108 94-10-160
Date: Tue, 1 Nov 1994 22:00:41 GMT

bart@cs.uoregon.edu (Barton C. Massey) writes:
> All this said, I too would like to see field rearrangement.
> There's several possibilities: my favorite suggestion is to
> forbid rearrangement to move fields past non-volatile fields
> (i.e. treat them as tombstones), and to force volatile structs
> to be completely unpadded and in order (possibly necessitating
> structure packing and unpacking across assignment).


Unfortunately, "volatile" is a pretty big sledgehammer to use just to get
field placement the way you want it. Declaring objects volatile disables
lots of useful optimizations that have nothing to do with structure-field
placement, such as elimination of redundant loads, common subexpression
elimination, and dead store elimination. That's a lot to give up just so I
can make the compiler lay out the structure the way I wanted.


As Robert Bedichek pointed out in a related article, lots of code would
break as a result of different compilations doing different structure
layouts. In practice, how would you make sure that compiling two source
files, which will eventually be linked together, get the same layout of the
same structure? You can't unless the compiler sees the whole program, I
think, and even then there is the operating system to consider, which is
*certainly* going to be compiled separately.


To put this another way, on what would you base your structure
rearrangement optimizations?


--
Bill Leonard
Harris Computer Systems Corporation
2101 W. Cypress Creek Road
Fort Lauderdale, FL 33309
Bill.Leonard@mail.csd.harris.com
--


Post a followup to this message

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