From 25c49abcf1621d8122309beb4693517787262bcb Mon Sep 17 00:00:00 2001 From: Marcel Keller Date: Mon, 6 Feb 2023 18:01:07 +1100 Subject: [PATCH] Fix complexity bug in allocation. --- Compiler/allocator.py | 3 ++- Compiler/util.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Compiler/allocator.py b/Compiler/allocator.py index e5c99a7b..b6816043 100644 --- a/Compiler/allocator.py +++ b/Compiler/allocator.py @@ -101,6 +101,7 @@ class StraightlineAllocator: self.dealloc |= reg.vector else: self.dealloc.add(reg) + reg.duplicates.remove(reg) base = reg.vectorbase seen = set_by_id() @@ -171,7 +172,7 @@ class StraightlineAllocator: for reg in self.alloc: for x in reg.get_all(): if x not in self.dealloc and reg not in self.dealloc \ - and len(x.duplicates) == 1: + and len(x.duplicates) == 0: print('Warning: read before write at register', x) print('\tregister trace: %s' % format_trace(x.caller, '\t\t')) diff --git a/Compiler/util.py b/Compiler/util.py index c1bedc27..6c3c3ce5 100644 --- a/Compiler/util.py +++ b/Compiler/util.py @@ -265,6 +265,9 @@ class set_by_id(object): def pop(self): return self.content.popitem()[1] + def remove(self, value): + del self.content[id(value)] + def __ior__(self, values): for value in values: self.add(value)