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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hubicka at gcc dot gnu.org

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #3)
> And the issue is:
> 
>   <bb 11> [local count: 1073741824]:
>   # idx_4 = PHI <0(2), idx_6(10)>
>   # PT = null
>   _3 = testtbl[idx_4].name;
> 
> we are missing constraints for the 'testtbl' initialization.

Which is because we do

          /* If this is a global variable with an initializer and we are in
             IPA mode generate constraints for it.  */
          ipa_ref *ref;
          for (unsigned idx = 0; vnode->iterate_reference (idx, ref); ++idx)
            {
              auto_vec<ce_s> rhsc;

but IPA references do not include pointers to STRING_CSTs:

(gdb) p vnode->debug ()
testtbl.0/3 (testtbl)
  Type: variable definition analyzed
  Visibility: semantic_interposition prevailing_def_ironly
  References: 
  Referring: main/2 (read) main/2 (read) 
  Availability: available
  Varpool flags: initialized used-by-single-function read-only
const-value-known


The following fixes this, though maybe IPA could have a flag
whether a variable refers to a constant pool entry instead, short
of making constant pool entries first class citizens.

diff --git a/gcc/tree-ssa-structalias.cc b/gcc/tree-ssa-structalias.cc
index d9356a82ad1..0367ff6bcaa 100644
--- a/gcc/tree-ssa-structalias.cc
+++ b/gcc/tree-ssa-structalias.cc
@@ -6554,6 +6554,18 @@ create_variable_info_for (tree decl, const char *name,
bool add_id)
                    process_constraint (new_constraint (lhs, *rhsp));
                }
            }
+
+         /* The above does not encode initialization from string constants,
+            so consider this possibility without a costly walk of
+            DECL_INITIAL.  */
+         struct constraint_expr lhs, temp;
+         temp.var = string_id;
+         temp.type = ADDRESSOF;
+         temp.offset = 0;
+         lhs.var = vi->id;
+         lhs.offset = 0;
+         lhs.type = SCALAR;
+         process_constraint (new_constraint (lhs, temp));
        }
     }


I noticed also we're using

          /* For escaped variables initialize them from nonlocal.  */
          if (!vnode->all_refs_explicit_p ())
            make_copy_constraint (vi, nonlocal_id);

so I assume all variables refered _from_ vnode are always explicit?

Reply via email to