https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100727

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
So it's fixed with

diff --git a/gcc/calls.c b/gcc/calls.c
index f3da1839dc5..74a5070605e 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -2397,6 +2397,7 @@ initialize_argument_information (int num_actuals
ATTRIBUTE_UNUSED,
             already in memory, instead of making a copy.  Likewise if we want
             to make the copy in the callee instead of the caller.  */
          if ((call_from_thunk_p || callee_copies)
+             && TREE_CODE (args[i].tree_value) != WITH_SIZE_EXPR
              && (base = get_base_address (args[i].tree_value))
              && TREE_CODE (base) != SSA_NAME
              && (!DECL_P (base) || MEM_P (DECL_RTL (base))))

where the get_base_address change lets WITH_SIZE_EXPR through now but not
before.  The only obvious followon difference is that we then do

              mark_addressable (args[i].tree_value);
...
              args[i].tree_value = build_fold_addr_expr_loc (loc,
                                                         args[i].tree_value);
              type = TREE_TYPE (args[i].tree_value);

unchanged is that we pass the argument by reference and that the target
requests callee_copies.

Now, this is variadic args, so maybe the callee_copies thing doesn't apply
and/or the varargs setup code now is inconsistent - in the end it's an
ABI change.

So given get_base_address only ever returned NULL for WITH_SIZE_EXPR
and clearly the !base check switches between ABIs we have to make the
WITH_SIZE_EXPR check explicit.

I'm also testing the additional (but then not needed)

diff --git a/gcc/gimple-expr.c b/gcc/gimple-expr.c
index b8c732b632a..c3211795d33 100644
--- a/gcc/gimple-expr.c
+++ b/gcc/gimple-expr.c
@@ -900,6 +900,8 @@ flush_mark_addressable_queue ()
 void
 mark_addressable (tree x)
 {
+  if (TREE_CODE (x) == WITH_SIZE_EXPR)
+    x = TREE_OPERAND (x, 0);
   while (handled_component_p (x))
     x = TREE_OPERAND (x, 0);
   if (TREE_CODE (x) == MEM_REF

Reply via email to