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.
{
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 */