[gcc r14-11421] Fix misoptimization at -O2 in LTO mode
Eric Botcazou
ebotcazou@gcc.gnu.org
Wed Mar 19 07:58:25 GMT 2025
https://gcc.gnu.org/g:5497ff92a38292d3b18ceb3fe284af83f3f8377e
commit r14-11421-g5497ff92a38292d3b18ceb3fe284af83f3f8377e
Author: Eric Botcazou <ebotcazou@adacore.com>
Date: Wed Mar 19 08:55:04 2025 +0100
Fix misoptimization at -O2 in LTO mode
This is a regression in recent releases. The problem is that the IPA mod/ref
pass looks through the (nominal) type of a pointer-to-discriminated-type
parameter in a call to a subprogram in order to see the (actual) type used
for the dereferences of the parameter in the callee, which is a
pointer-to-constrained-subtype.
Historically the discriminated type is marked with the may_alias attribute
because of the symmetric effect for the argument in the caller, so we mark
the constrained subtype with the attribute now for the sake of the callee.
gcc/ada/
* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Record_Subtype>: Set
the may_alias attribute if a specific GCC type is built.
Diff:
---
gcc/ada/gcc-interface/decl.cc | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index ca174bff0097..53b5e5962181 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -3564,6 +3564,14 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
TYPE_PACKED (gnu_type) = TYPE_PACKED (gnu_base_type);
TYPE_REVERSE_STORAGE_ORDER (gnu_type)
= Reverse_Storage_Order (gnat_entity);
+
+ /* Do the same for subtypes as for the base type, since pointers
+ to them may symmetrically also point to the latter. */
+ prepend_one_attribute
+ (&attr_list, ATTR_MACHINE_ATTRIBUTE,
+ get_identifier ("may_alias"), NULL_TREE,
+ gnat_entity);
+
process_attributes (&gnu_type, &attr_list, true, gnat_entity);
/* Set the size, alignment and alias set of the type to match
More information about the Gcc-cvs
mailing list