This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 1/6] combine: undo_to_marker
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: gcc-patches at gcc dot gnu dot org
- Cc: dje dot gcc at gmail dot com, Segher Boessenkool <segher at kernel dot crashing dot org>
- Date: Sun, 10 May 2015 09:13:50 -0700
- Subject: [PATCH 1/6] combine: undo_to_marker
- Authentication-results: sourceware.org; auth=none
- References: <cover dot 1431268134 dot git dot segher at kernel dot crashing dot org>
- References: <cover dot 1431268134 dot git dot segher at kernel dot crashing dot org>
This generalises undo_all to allow undoing only the last some SUBSTs.
This is used by the next patch, but is more generally useful.
Comments?
Segher
2015-05-10 Segher Boessenkool <segher@kernel.crashing.org>
* combine.c (get_undo_marker): New function.
(undo_to_marker): New function, largely factored out from ...
(undo_all): ... this. Adjust.
---
gcc/combine.c | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/gcc/combine.c b/gcc/combine.c
index b806959..1e4d65e 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -4643,15 +4643,25 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0,
return newi2pat ? i2 : i3;
}
-/* Undo all the modifications recorded in undobuf. */
+/* Get a marker for undoing to the current state. */
+
+static void *
+get_undo_marker (void)
+{
+ return undobuf.undos;
+}
+
+/* Undo the modifications up to the marker. */
static void
-undo_all (void)
+undo_to_marker (void *marker)
{
struct undo *undo, *next;
- for (undo = undobuf.undos; undo; undo = next)
+ for (undo = undobuf.undos; undo != marker; undo = next)
{
+ gcc_assert (undo);
+
next = undo->next;
switch (undo->kind)
{
@@ -4675,7 +4685,15 @@ undo_all (void)
undobuf.frees = undo;
}
- undobuf.undos = 0;
+ undobuf.undos = (struct undo *) marker;
+}
+
+/* Undo all the modifications recorded in undobuf. */
+
+static void
+undo_all (void)
+{
+ undo_to_marker (0);
}
/* We've committed to accepting the changes we made. Move all
--
1.8.1.4