[Bug tree-optimization/102714] [11/12 Regression] A volatile-related problem cased by ipa inline pass

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Oct 13 07:09:56 GMT 2021


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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
           Priority|P3                          |P2
            Summary|A volatile-related problem  |[11/12 Regression] A
                   |cased by ipa inline pass    |volatile-related problem
                   |                            |cased by ipa inline pass
           Keywords|                            |wrong-code
   Last reconfirmed|                            |2021-10-13
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
                 CC|                            |jamborm at gcc dot gnu.org
     Ever confirmed|0                           |1
      Known to fail|                            |11.2.0
   Target Milestone|---                         |11.3

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed, it seems to be IPA SRA losing the volatile (maybe it should just
exempt itself from touching those).

Summary for node __radix_tree_lookup/6:
...
  Summary for edge __radix_tree_lookup/6->radix_tree_load_root/5:
    return value ignored
    Parameter 0:
      Scalar param sources: 0
      Pointer pass through from the param given above, safe_to_import_accesses:
0
...
Summary for node radix_tree_load_root/5:
  Returns value
  Descriptor for parameter 0:
    param_size_limit: 16, size_reached: 8, by_ref
    * Access to unit offset: 8, unit size: 8, type: void * const,
alias_ptr_type: void * *, certain
...

Evaluating analysis results for radix_tree_load_root/5
  Will remove return value.
  Will split parameter 0
    - component at byte offset 8, size 8

  Created adjustments:
    m_always_copy_start: 3
    IPA adjusted parameters: 0. IPA_PARAM_OP_SPLIT , offset: 8, base_index: 0,
prev_clone_index: 0, type:  <pointer_type 0x7ffff669f5e8>, alias type: 
<pointer_type 0x7ffff656c3f0> prefix: ISRA
                             1. IPA_PARAM_OP_COPY , base_index: 1,
prev_clone_index: 1
                             2. IPA_PARAM_OP_COPY , base_index: 2,
prev_clone_index: 2
    Will SKIP return.
  Created new node radix_tree_load_root.isra/10

and it materializes the load in the caller.  While in this case it might
very well materialize a volatile load generally it will be difficult
to match the exact volatile loads (and their order) so it will be best
to disqualify parameters involved in volatile accesses from any IPA
SRA transform.  Interestingly enough the local analysis with
isra_track_scalar_param_local_uses on the param returns -1 ...

But we continue with

      if (POINTER_TYPE_P (type))
        {
          type = TREE_TYPE (type);

          if (TREE_CODE (type) == FUNCTION_TYPE
              || TREE_CODE (type) == METHOD_TYPE)
            {
              if (dump_file && (dump_flags & TDF_DETAILS))
                fprintf (dump_file, " not a candidate, reference to "
                         "a function\n");
              continue;
            }
          if (TYPE_VOLATILE (type))
            {
              if (dump_file && (dump_flags & TDF_DETAILS))
                fprintf (dump_file, " not a candidate, reference to "
                         "a volatile type\n");

but well - just volatileness of the type doesn't mean anything ...
ptr_parm_has_nonarg_uses then does

      if (gimple_assign_single_p (stmt))
        {
          tree rhs = gimple_assign_rhs1 (stmt);
          while (handled_component_p (rhs))
            rhs = TREE_OPERAND (rhs, 0);
          if (TREE_CODE (rhs) == MEM_REF
              && TREE_OPERAND (rhs, 0) == name
              && integer_zerop (TREE_OPERAND (rhs, 1))
              && types_compatible_p (TREE_TYPE (rhs),
                                     TREE_TYPE (TREE_TYPE (name)))
              && !TREE_THIS_VOLATILE (rhs))
            uses_ok++;

but the TREE_THIS_VOLATILE check is misplaced and should be at the _outermost_
component-ref.  (side-note - it also feels like this misses an alignment
check)

I have a patch.


More information about the Gcc-bugs mailing list