Commit 09d13a5f authored by Kevin Modzelewski's avatar Kevin Modzelewski

Proper memory freeing behavior, courtesy of Travis

parent 0132e2d3
......@@ -650,18 +650,11 @@ void Rewriter::abort() {
assert(!finished);
finished = true;
// This feels hacky: are we really guaranteed to find all of the things we need to delete?
std::unordered_set<RewriterVar*> found;
for (const auto& p : vars_by_location) {
found.insert(p.second);
for (auto v : args) {
v->decUse();
}
for (const auto v : live_outs) {
found.insert(v);
}
for (auto v : found) {
delete v;
for (auto v : live_outs) {
v->decUse();
}
}
......
......@@ -144,12 +144,12 @@ public:
static RewriterVarUsage empty();
#ifndef NDEBUG
~RewriterVarUsage() {
if (!std::uncaught_exception())
assert(done_using);
if (!done_using) {
assert(std::uncaught_exception());
setDoneUsing();
}
}
#endif
void setDoneUsing();
bool isDoneUsing();
......@@ -278,6 +278,8 @@ public:
this->abort();
assert(finished);
// This check isn't thread safe and should be fine to remove if it causes
// issues (along with the nvars/start_vars accounting)
ASSERT(RewriterVar::nvars == start_vars, "%d %d", RewriterVar::nvars, start_vars);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment