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] |
Tested on i686-linux, committed on trunk Remove the max_alignment kludge on x86, by adding two kinds of max alignments: Maximum alignment that the compiler might choose by default for a type or object. And maximum alignment known to be honored by the target default allocator. -- Also, for the renaming of a constant, Gigi was unconditionally applying the optimization of copying the rvalue. But, if the constant is aliased, it is valid to evaluate both the Access attribute of the constant and that of the renaming; moreover, they must compare equal. The change makes it so that the lvalue is copied instead, in the case of the renaming of an aliased constant, while keeping the optimization in the non-aliased case. An additional tweak is implemented in the latter case, if the renamed constant is a stand-alone object: the lvalue is copied as well as the rvalue, thus avoiding to create an additional object if this happens at the library level (this is GCC PR ada/19037). -- The Ada RM grants some leeway to the implementation when it comes to supporting alignment and size clauses for (stand-alone) objects. However a requirement is that a "confirming" clause be accepted for them, that is to say a clause that would specify the alignment and size that would be given to the object in the absence of any clause. Because the back-end is ultimately responsible for laying out the objects, given that Gigi only operates on types, some low-level platform-dependent adjustments may be applied to objects that cannot be replicated by representation clauses at the language level. This change instructs the compiler to annotate alignment and size of objects with the values picked from the type built for it by Gigi, thus disregarding these low-level adjustments. The following code must yield the same -gnatR3 output on all platforms: package P is X : constant String := "abc"; end P; Representation information for unit P (spec) -------------------------------------------- for X'Size use 24; for X'Alignment use 1; -- Then, when we determine what GCC node to return for a front-end N_Identifier node, if we have a constant declaration and its initializer at hand, we return the latter as often as possible to avoid the need to call fold in lots of places and the need of elaboration code if this Id is used as an initializer itself. Still, if there is a variable declaration associated with the constant, we want/have-to to return that variable instead of the CST value if the parent requires an lvalue. A typical case is a subprogram call parameter passed by reference, and the code to detect that was overlooking the fact that such a parameter could be nested within a parameter association list entry. This resulted in unexpected copies of possibly large composite constant values when used as subprograms actual in named associations. The fix applied here is an adjustment to the "lvalue_required_p" predicate, to process a parameter association context as subprogram calls, plugging the aforementioned oversight. See gnat.dg/addr2.adb -- Finally, for an aliased object whose type is the constructed subtype of an array whose nominal subtype is unconstrained, Gigi makes a type that includes a template. The initializer of the object (a reference to an unconstrained object) is then converted to this type, which yields a constructor. If the object happens to stay unmodified after being constructed, a read-only variant of the type is built and the initializer is again converted to it. There are 2 cases: - the element type is constrained; in this case, the array component of the constructor is fetched and reused to build the new constructor. - the element type is unconstrained; in this case, the result is a couple of nested constructors whose outer member references the array component of the inner one. In the second case, gimplification will abort when the gimplifier is trying to create a temporary for the inner constructor. The fix is to arrange for the array component to be fetched in the second case too. See gnat.dg/aliased1.adb 2007-08-14 Olivier Hainque <hainque@adacore.com> Eric Botcazou <ebotcazou@adacore.com> * targtyps.c (get_target_maximum_default_alignment): New function. Maximum alignment that the compiler might choose by default for a type or object. (get_target_default_allocator_alignment): New function. Alignment known to be honored by the target default allocator. (get_target_maximum_allowed_alignment): New function. Maximum alignment we might accept for any type or object on the target. (get_target_maximum_alignment): Now synonym of maximum_default_alignment * gigi.h (get_target_maximum_default_alignment): Declare new function. (get_target_default_allocator_alignment): Likewise. (get_target_maximum_allowed_alignment): Likewise. PR ada/19037 * decl.c (gnat_to_gnu_entity) <object>: Except for the renaming of the result of a function call, first try to use a stabilized reference for a constant renaming too. (validate_alignment): Use target_maximum_allowed_alignment instead of MAX_OFILE_ALIGNMENT as the upper bound to what we accept. (gnat_to_gnu_entity): Use common nodes directly. (gnat_to_gnu_entity) <object>: Pick the values of the type to annotate alignment and size for the object. (lvalue_required_p): Handle N_Parameter_Association like N_Function_Call and N_Procedure_Call_Statement. (takes_address): Rename to lvalue_required_p, add third parameter 'aliased' and adjust recursive calls. <N_Indexed_Component>: Update 'aliased' from the array type. <N_Selected_Component>: New case. <N_Object_Renaming_Declaration>: New Likewise. (Identifier_to_gnu): Adjust for above changes. (maybe_stabilize_reference) <CONST_DECL>: New case. * utils2.c (build_binary_op) <ARRAY_RANGE_REF>: Look through conversion between type variants. (build_simple_component_ref): Likewise. (build_call_alloc_dealloc): Use target_default_allocator_alignment instead of BIGGEST_ALIGNMENT as the threshold to trigger the super aligning type circuitry for allocations from the default storage pool. (build_allocator): Likewise. (build_simple_component_ref): Manually fold the reference for a constructor if the record type contains a template. * utils.c (value_zerop): Delete. (gnat_init_decl_processing): Emit debug info for common types. (rest_of_record_type_compilation): If a union contains a field with a non-constant qualifier, treat it as variable-sized. (finish_record_type): Give the stub TYPE_DECL a name. (rest_of_record_type_compilation): Likewise. (convert) <CONSTRUCTOR>: New case. Build a new constructor if types are equivalent array types. (create_field_decl): Claim fields of any ARRAY_TYPE are addressable, even if the type is not passed by reference. (static_ctors, static_dtors): Delete. (end_subprog_body): Do not record constructors and destructors. (build_global_cdtor): Delete. (gnat_write_global_declarations): Do not call build_global_cdtor. * lang-specs.h: If TARGET_VXWORKS_RTP is defined, append -mrtp when -fRTS=rtp is specified. If CONFIG_DUAL_EXCEPTIONS is 1, append -fsjlj when -fRTS=sjlj is specified. * misc.c (gnat_init_gcc_eh): Use __gnat_eh_personality_sj for the name of the personality function with SJLJ exceptions. * raise-gcc.c (PERSONALITY_FUNCTION): Use __gnat_eh_personality_sj for the name of the personality function with SJLJ exceptions.
Attachment:
difs
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |