summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormiod <miod@openbsd.org>2013-08-06 19:02:37 +0000
committermiod <miod@openbsd.org>2013-08-06 19:02:37 +0000
commit016dfe1afca3898759dfc06c82acbe86f2c39560 (patch)
tree4e15e41460fba1f01a62cf3d7440f1daa05e3f7d
parentscalbnf on vax, okay miod@ (diff)
downloadwireguard-openbsd-016dfe1afca3898759dfc06c82acbe86f2c39560.tar.xz
wireguard-openbsd-016dfe1afca3898759dfc06c82acbe86f2c39560.zip
One major difference between gcc 2.95 and gcc 3, is that the latter comes
with an optimization pass which attemps to identify and remove dead stores. Unfortunately, this logic assumes that a given rtl MEM reference can only refer to register contents and values, but not further dereference memory. This is not true of all addressing modes on vax, and this causes gcc 3 to consider as dead stores everything which can be expressed as *offset(register) in vax assembly. The canonical example of this is linked list insertion or removal, with instructions such as "item->prev->next = item->next" being wrongly optimized out, and cause double frees or other funny linking problems later on. Add a knob to disable the troublesome part of that optimization pass, and only enable this knob on vax. This gives a native vax gcc 3 compiler able to rebuild the world.
-rw-r--r--gnu/usr.bin/gcc/gcc/config/vax/vax.h4
-rw-r--r--gnu/usr.bin/gcc/gcc/flow.c2
2 files changed, 6 insertions, 0 deletions
diff --git a/gnu/usr.bin/gcc/gcc/config/vax/vax.h b/gnu/usr.bin/gcc/gcc/config/vax/vax.h
index 41090f96ab3..8d36e2cc355 100644
--- a/gnu/usr.bin/gcc/gcc/config/vax/vax.h
+++ b/gnu/usr.bin/gcc/gcc/config/vax/vax.h
@@ -1228,3 +1228,7 @@ VAX operand formatting codes:
actually have any code whatsoever for which this isn't overridden
by the proper FDE definition. */
#define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, PC_REGNUM)
+
+/* Tell flow.c not to try and optimize away MEM dead stores, as its
+ logic is confused by some of the addressing modes of the VAX. */
+#define FLOW_DEAD_STORES_BROKEN_P
diff --git a/gnu/usr.bin/gcc/gcc/flow.c b/gnu/usr.bin/gcc/gcc/flow.c
index 9f5e1924e91..e902ff6b377 100644
--- a/gnu/usr.bin/gcc/gcc/flow.c
+++ b/gnu/usr.bin/gcc/gcc/flow.c
@@ -2702,10 +2702,12 @@ mark_set_1 (pbi, code, reg, cond, insn, flags)
if (insn && GET_CODE (reg) == MEM)
for_each_rtx (&PATTERN (insn), invalidate_mems_from_autoinc, pbi);
+#ifndef FLOW_DEAD_STORES_BROKEN_P
if (GET_CODE (reg) == MEM && ! side_effects_p (reg)
/* ??? With more effort we could track conditional memory life. */
&& ! cond)
add_to_mem_set_list (pbi, canon_rtx (reg));
+#endif
}
if (GET_CODE (reg) == REG