Skip to content

Commit

Permalink
Fixed RemoveUnusedMemory to also consider MemoryObjects that are only…
Browse files Browse the repository at this point in the history
… pointed to by initial values of other MemoryObjects.
  • Loading branch information
ThomasHaas committed Aug 15, 2023
1 parent 9a9120b commit b5e89bb
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ public void run(Program program) {
final Memory memory = program.getMemory();
final MemoryObjectCollector collector = new MemoryObjectCollector();
program.getThreadEvents(RegReader.class).forEach(r -> r.transformExpressions(collector));
// Also add MemoryObjects referenced by initial values (this does happen in Litmus code)
for (MemoryObject obj : memory.getObjects()) {
for (int field : obj.getStaticallyInitializedFields()) {
if (obj.getInitialValue(field) instanceof MemoryObject memObj) {
collector.memoryObjects.add(memObj);
}
}
}
Sets.difference(memory.getObjects(), collector.memoryObjects).forEach(memory::deleteMemoryObject);
}

Expand Down

0 comments on commit b5e89bb

Please sign in to comment.