When a memory copy operation is analyzed by analyze_ssa_name, if both the
load and store are made through the same SSA name, the store is overlooked.
gcc/
* ipa-modref.cc (modref_eaf_analysis::analyze_ssa_name): Always
process both the load and the store of a memory copy operation.
gcc/testsuite/
* gcc.dg/ipa/modref-4.c: New test.
is used arbitrarily. */
if (memory_access_to (gimple_assign_rhs1 (assign), name))
m_lattice[index].merge (deref_flags (0, false));
+
/* Handle *name = *exp. */
- else if (memory_access_to (gimple_assign_lhs (assign), name))
+ if (memory_access_to (gimple_assign_lhs (assign), name))
m_lattice[index].merge_direct_store ();
}
/* Handle lhs = *name. */
--- /dev/null
+/* { dg-options "-O" } */
+/* { dg-do run } */
+
+static __attribute__((noipa)) int foo (void)
+{
+ return 1;
+}
+
+int main (void)
+{
+ struct S { int a; int b; };
+ struct T { struct S s; };
+
+ struct T t = { { 0, 0 } };
+ struct T u;
+
+ __attribute__((noinline)) void bar (void)
+ {
+ if (foo ())
+ {
+ u = t;
+ /* OK with u.s.a = 0; */
+ }
+ }
+
+ u.s.a = 1;
+
+ bar ();
+
+ if (u.s.a != 0)
+ __builtin_abort ();
+
+ return 0;
+}