This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
[RFC] ABI change for variable sized types
- From: Richard Henderson <rth at redhat dot com>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 14 Jul 2004 14:56:39 -0700
- Subject: [RFC] ABI change for variable sized types
So I've been working for about 2 weeks trying to come up with a design
to break the tree/rtl phase ordering problem in assign_parms. I've
implemented and discarded as flawed three variations on that theme.
Having spent Sunday night scratching out a design for a fourth try, I
was cranky Monday morning when I logged on to the gcc irc channel and
offered a contract killing on whomever first thought variable-sized
pass-by-value was a good idea.
Then David Edelsohn asked me why we didn't just change the ABI.
Somehow, it had never occurred to me that this was an option. One
I've grown more and more fond of as I've thought about it over the
past two days.
It would affect, as far as I can tell, only Ada, and only in cases
in which the size of the type is variable but whose size is not
computed from the object itself (CONTAINS_PLACEHOLDER_P).
The cases of variable sized structures as GCC extensions in C are,
as far as I can tell, only valid in the context of nested functions.
Which means that the functions are private to the translation unit,
and thus there is no ABI change.
Further, it would affect only a subset of targets:
alpha avr c4x h8 i386
i860 ip2k m32r m68hc11 m68k
ns32k pdp11 stormy16 vax
xtensa
It would not affect
arc arm cris fr30 frv
x86-64 ia64 iq2000 m32r mcore
mips mmix mn10300 pa rs6000
s390 sh sparc v850
as these targets already pass all variable sized types by reference.
If it weren't for i386, the "no one cares" factor would probably be
high enough to make this change unilaterally.
I believe I've now cleaned up all of the backends such that making
this change is the simplest of patches, as appended.
If this proposal is rejected, I'll go back to my fourth design.
I do have some hope of it actually working, but it'll be complex.
Thoughts?
r~
* function.c (pass_by_reference): True for any variable sized type.
Index: function.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.c,v
retrieving revision 1.557
diff -c -p -d -r1.557 function.c
*** function.c 14 Jul 2004 07:30:19 -0000 1.557
--- function.c 14 Jul 2004 21:24:24 -0000
*************** pass_by_reference (CUMULATIVE_ARGS *ca,
*** 2039,2047 ****
if (TREE_ADDRESSABLE (type))
return true;
! /* If an object's size is dependent on itself, there's no way
! to *not* pass by reference. */
! if (CONTAINS_PLACEHOLDER_P (TYPE_SIZE (type)))
return true;
}
--- 2039,2046 ----
if (TREE_ADDRESSABLE (type))
return true;
! /* GCC post 3.4 passes *all* variable sized types by reference. */
! if (!TYPE_SIZE (type) || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
return true;
}