Rewrite of codegen-level struct/union layout

Per subject, attached patch almost completely rewrites the
struct/union algorithm. The new version is a lot simpler; some of
that was refactoring code, and some of that was depending a lot more
on the information already calculated by the ASTContext.

Depending on the ASTContext to do struct layout should make it easier
to add support for constructs like packed and aligned, because this
will pick up any changes in the way the ASTContext does struct layout
for free.

On a side note, after I finished this patch, PHP compiled with clang
started working. I'm not sure if I fixed a struct layout bug, or some
other change in my tree helped, but it was crashing on startup before
this patch, and now it passes most of its testsuite (although this is
with most of the extensions disabled).

-Eli

t.txt (13 KB)

Per subject, attached patch almost completely rewrites the
struct/union algorithm. The new version is a lot simpler; some of
that was refactoring code, and some of that was depending a lot more
on the information already calculated by the ASTContext.

Depending on the ASTContext to do struct layout should make it easier
to add support for constructs like packed and aligned, because this
will pick up any changes in the way the ASTContext does struct layout
for free.

On a side note, after I finished this patch, PHP compiled with clang
started working. I'm not sure if I fixed a struct layout bug, or some
other change in my tree helped, but it was crashing on startup before
this patch, and now it passes most of its testsuite (although this is
with most of the extensions disabled).

Wow!

Great news,

snaroff

Per subject, attached patch almost completely rewrites the
struct/union algorithm. The new version is a lot simpler; some of
that was refactoring code, and some of that was depending a lot more
on the information already calculated by the ASTContext.

Depending on the ASTContext to do struct layout should make it easier
to add support for constructs like packed and aligned, because this
will pick up any changes in the way the ASTContext does struct layout
for free.

One thing to note is, struct layout is very much target specific and not all target specific information is required for Semantic Analysis.

I have not looked at your patch at all. I'll look at it and get back to you as soon as I can.

On a side note, after I finished this patch, PHP compiled with clang
started working. I'm not sure if I fixed a struct layout bug, or some
other change in my tree helped, but it was crashing on startup before
this patch, and now it passes most of its testsuite (although this is
with most of the extensions disabled).

Cool.

Hmm? We need to be able to compute the size and alignment of arbitrary
structures in Sema, and we need to be able to compute the positions of
arbitrary non-bitfield members in Sema. What exactly is left that
Sema doesn't need?

-Eli

Very nice!

-Chris