aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2021-01-15 16:45:41 +0000
committerRichard Sandiford <richard.sandiford@arm.com>2021-01-15 16:45:41 +0000
commitf2cc526f47acbeeddd77b706a212b4703562e57f (patch)
treedaa358a815290aa5f13969d954e03e4ef6d7875d /gcc
parent7f6cdaa9a8da173ab9e93009f5b7ff427c7f964d (diff)
downloadgcc-f2cc526f47acbeeddd77b706a212b4703562e57f.zip
gcc-f2cc526f47acbeeddd77b706a212b4703562e57f.tar.gz
gcc-f2cc526f47acbeeddd77b706a212b4703562e57f.tar.bz2
recog: Fix insn_change_watermark destructor
Noticed while working on something else that the insn_change_watermark destructor could call cancel_changes for changes that no longer exist. The loop in cancel_changes is a nop in that case, but: num_changes = num; can mess things up. I think this would only affect nested uses of insn_change_watermark. gcc/ * recog.h (insn_change_watermark::~insn_change_watermark): Avoid calling cancel_changes for changes that no longer exist.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/recog.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/recog.h b/gcc/recog.h
index 269094a..e96e66e 100644
--- a/gcc/recog.h
+++ b/gcc/recog.h
@@ -547,13 +547,19 @@ class insn_change_watermark
{
public:
insn_change_watermark () : m_old_num_changes (num_validated_changes ()) {}
- ~insn_change_watermark () { cancel_changes (m_old_num_changes); }
+ ~insn_change_watermark ();
void keep () { m_old_num_changes = num_validated_changes (); }
private:
int m_old_num_changes;
};
+inline insn_change_watermark::~insn_change_watermark ()
+{
+ if (m_old_num_changes < num_validated_changes ())
+ cancel_changes (m_old_num_changes);
+}
+
#endif
#endif /* GCC_RECOG_H */