+2019-07-29 Richard Sandiford <richard.sandiford@arm.com>
+
+ PR debug/86638
+ * tree-ssa-dce.c (keep_all_vdefs_p): New function.
+ (mark_stmt_if_obviously_necessary): Mark all stmts with vdefs as
+ necessary if keep_all_vdefs_p is true.
+ (mark_aliased_reaching_defs_necessary): Add a gcc_checking_assert
+ that keep_all_vdefs_p is false.
+ (mark_all_reaching_defs_necessary): Likewise.
+ (propagate_necessity): Skip the vuse scan if keep_all_vdefs_p is true.
+
2019-07-29 Richard Sandiford <richard.sandiford@arm.com>
* common.opt (Og): Change the initial value of flag_dse to 0.
+2019-07-29 Richard Sandiford <richard.sandiford@arm.com>
+
+ * c-c++-common/guality/Og-dce-1.c: New test.
+ * c-c++-common/guality/Og-dce-2.c: Likewise.
+ * c-c++-common/guality/Og-dce-3.c: Likewise.
+
2019-07-29 Richard Sandiford <richard.sandiford@arm.com>
* c-c++-common/guality/Og-global-dse-1.c: New test.
--- /dev/null
+/* { dg-do run } */
+/* { dg-options "-g" } */
+
+int *__attribute__((noipa)) consume (int *ptr) { return ptr; }
+
+int
+main (void)
+{
+ int x;
+ int *volatile ptr = consume (&x);
+ x = 0;
+ x = 1; /* { dg-final { gdb-test . "*ptr" "0" } } */
+ return 0; /* { dg-final { gdb-test . "*ptr" "1" } } */
+}
--- /dev/null
+/* { dg-do run } */
+/* { dg-options "-g" } */
+
+struct s { int a, b, c, d; };
+
+struct s gs1 = { 1, 2, 3, 4 };
+struct s gs2 = { 5, 6, 7, 8 };
+
+struct s *__attribute__((noipa)) consume (struct s *ptr) { return ptr; }
+
+int
+main (void)
+{
+ struct s x;
+ struct s *volatile ptr = consume (&x);
+ x = gs1;
+ x = gs2; /* { dg-final { gdb-test . "ptr->a" "1" } } */
+ return 0; /* { dg-final { gdb-test . "ptr->a" "5" } } */
+}
--- /dev/null
+/* { dg-do run } */
+/* { dg-options "-g" } */
+
+volatile int amount = 10;
+
+void __attribute__((noipa))
+do_something (int *ptr)
+{
+ *ptr += 10;
+}
+
+int __attribute__((noipa))
+foo (int count)
+{
+ int x = 1;
+ for (int i = 0; i < count; ++i)
+ do_something (&x); /* { dg-final { gdb-test . "x" "1" } } */
+ int res = x; /* { dg-final { gdb-test . "x" "101" } } */
+ x = res + 1;
+ return res; /* { dg-final { gdb-test . "x" "102" } } */
+
+}
+
+int
+main (void)
+{
+ foo (10);
+ return 0;
+}
static int *bb_postorder;
+/* True if we should treat any stmt with a vdef as necessary. */
+
+static inline bool
+keep_all_vdefs_p ()
+{
+ return optimize_debug;
+}
+
/* If STMT is not already marked necessary, mark it, and add it to the
worklist if ADD_TO_WORKLIST is true. */
return;
}
+ if (gimple_vdef (stmt) && keep_all_vdefs_p ())
+ {
+ mark_stmt_necessary (stmt, true);
+ return;
+ }
+
return;
}
static void
mark_aliased_reaching_defs_necessary (gimple *stmt, tree ref)
{
+ /* Should have been caught before calling this function. */
+ gcc_checking_assert (!keep_all_vdefs_p ());
+
unsigned int chain;
ao_ref refd;
gcc_assert (!chain_ovfl);
static void
mark_all_reaching_defs_necessary (gimple *stmt)
{
+ /* Should have been caught before calling this function. */
+ gcc_checking_assert (!keep_all_vdefs_p ());
walk_aliased_vdefs (NULL, gimple_vuse (stmt),
mark_all_reaching_defs_necessary_1, NULL, &visited);
}
if (!use)
continue;
+ /* No need to search for vdefs if we intrinsicly keep them all. */
+ if (keep_all_vdefs_p ())
+ continue;
+
/* If we dropped to simple mode make all immediately
reachable definitions necessary. */
if (chain_ovfl)