This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hello, The GCC 3.x series supported temporaries of variable size for which a constant upper bound could be obtained, thanks to specific bits in assign_temp, still there in mainline: /* Unfortunately, we don't yet know how to allocate variable-sized temporaries. However, sometimes we have a fixed upper limit on the size (which is stored in TYPE_ARRAY_MAX_SIZE) and can use that instead. ... /* If we still haven't been able to get a size, see if the language can compute a maximum size. */ GCC 4 currently rejects any creation attempt very early, from create_tmp_var: /* We don't allow types that are addressable (meaning we can't make copies), incomplete, or of variable size. */ This leads to an ICE on the Ada testcase below, expected to compile silently - a regression from GCC 3.4. procedure P (Nbytes : Natural) is type Message_T (Length : Natural) is record case Length is when 0 => null; when others => Id : Natural; end case; end record; type Local_Message_T is new Message_T (Nbytes); function One_message return Local_Message_T is M : Local_Message_T; begin if M.Length > 0 then M.Id := 1; end if; return M; end; procedure Process (X : Local_Message_T) is begin null; end; begin Process (One_Message); end; The attached patch is a suggestion to address this by removing the check in create_tmp_var and have gimple_add_tmp_var adjust the var decl size when it is variable to denote a constant upper bound instead, aborting if no such bound can be obtained. The upper bound evaluation eventually resorts to a "max_int_size_in_bytes (type)" helper in tree.c, inspired from the initial code in assign_temp and reused there as well. Along with this comes an adjustment to the Ada front-end type_max_size hook, to let it provide constant values in more situations than what it was capable of so far. Bootstrapped and regression tested on i686-pc-linux-gnu with languages=all,ada. Thanks in advance, Olivier ----------------------- 2006-05-23 Olivier Hainque <hainque@adacore.com> * tree.c (max_int_size_in_bytes): New function, inspired from code in function.c:assign_temp. * tree.h (max_int_size_in_bytes): Declare. * function.c (assign_temp): Use it. * gimplify.c (create_tmp_var): Relax the assertions on the type properties, not mandating constant size any more. (force_constant_size): New static function. (gimple_add_tmp_var): Use it, forcing variable size to a constant upper bound if it is not constant on entry. * ada/misc.c (gnat_type_max_size): Look at TYPE_ADA_SIZE if we have not been able to get a constant upper bound from TYPE_SIZE_UNIT.
Attachment:
vsize-temp.dif
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |