retention of superseded AST elements to prevent pointer mis-aliasing

This commit is contained in:
Vern Paxson 2023-11-05 16:28:13 -08:00 committed by Arne Welzel
parent 280acc51bf
commit 4ec9a23ce6
9 changed files with 103 additions and 23 deletions

View file

@ -557,6 +557,7 @@ ConstExprPtr Reducer::Fold(ExprPtr e) {
}
void Reducer::FoldedTo(ExprPtr e, ConstExprPtr c) {
om.AddObj(e.get());
constant_exprs[e.get()] = std::move(c);
folded_exprs.push_back(std::move(e));
}
@ -712,6 +713,8 @@ IDPtr Reducer::GenTemporary(TypePtr t, ExprPtr rhs, IDPtr id) {
temp_id->SetType(t);
temps.push_back(temp);
om.AddObj(temp_id.get());
ids_to_temps[temp_id.get()] = temp;
return temp_id;
@ -760,6 +763,7 @@ IDPtr Reducer::GenLocal(const IDPtr& orig) {
prev = orig_to_new_locals[orig.get()];
AddNewLocal(local_id);
om.AddObj(orig.get());
orig_to_new_locals[orig.get()] = local_id;
if ( ! block_locals.empty() && ret_vars.count(orig.get()) == 0 )