gcc-ssa-generation.patch raw

   1  This patch can be removed when using GCC 14.4, 15.3 or 16.x.
   2  14.x: https://github.com/gcc-mirror/gcc/commit/2d7099faa5c59b871e3027268d70a8a46d892824
   3  15.x: https://github.com/gcc-mirror/gcc/commit/7debee2cb6503b2af0f1d43b0e56b759474396d5
   4  16.x: https://github.com/gcc-mirror/gcc/commit/c6085ca0ed4cef3bcf4eb382cb71e44219c10f6e
   5  
   6  commit b46614ebfc57ccca8a050668ad0e8ba5968c5943
   7  Author: Jakub Jelinek <jakub@redhat.com>
   8  Date:   Tue Jan 6 08:36:20 2026 +0100
   9  
  10      tree-object-size: Deterministic SSA generation [PR123351]
  11      
  12      The order of evaluation of function arguments is unspecified in C++.
  13      The function object_sizes_set_temp called object_sizes_set with two
  14      calls to make_ssa_name() as arguments.  Since make_ssa_name() has the
  15      side effect of incrementing the global SSA version counter, different
  16      architectures of the same compiler evaluated these calls in different
  17      orders.
  18      
  19      This resulted in non-deterministic SSA version numbering between
  20      x86_64 and aarch64 hosts during cross-compilation, leading to
  21      divergent object files.
  22      
  23      Sequencing the calls into separate statements ensures deterministic
  24      evaluation order.
  25  
  26      https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123351
  27      https://gcc.gnu.org/pipermail/gcc-patches/2026-January/704817.html
  28      
  29      2026-01-06  Jakub Jelinek  <jakub@redhat.com>
  30                  Marco Falke  <falke.marco@gmail.com>
  31      
  32              PR tree-optimization/123351
  33              * tree-object-size.cc (object_sizes_set_temp): Separate calls to
  34              make_ssa_name to ensure deterministic execution order.
  35  
  36  diff --git a/gcc/tree-object-size.cc b/gcc/tree-object-size.cc
  37  index 018fbc30cbb..24e7d710371 100644
  38  --- a/gcc/tree-object-size.cc
  39  +++ b/gcc/tree-object-size.cc
  40  @@ -319,9 +319,11 @@ object_sizes_set_temp (struct object_size_info *osi, unsigned varno)
  41     tree val = object_sizes_get (osi, varno);
  42   
  43     if (size_initval_p (val, osi->object_size_type))
  44  -    object_sizes_set (osi, varno,
  45  -		      make_ssa_name (sizetype),
  46  -		      make_ssa_name (sizetype));
  47  +    {
  48  +      val = make_ssa_name (sizetype);
  49  +      tree wholeval = make_ssa_name (sizetype);
  50  +      object_sizes_set (osi, varno, val, wholeval);
  51  +    }
  52   }
  53   
  54   /* Initialize OFFSET_LIMIT variable.  */
  55