aboutsummaryrefslogtreecommitdiffhomepage
path: root/ir.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2023-06-26 00:29:07 +0200
committerlemon <lsof@mailbox.org>2023-06-26 00:29:07 +0200
commitb94fe89c9ddfcb85dcddebfd218fa7f00b8e6608 (patch)
tree153c345c5811343bb0f8f5190ead67f9f70b0d97 /ir.c
parentbdb0276b534b817afb0b79f8e63196eed5d8bd7f (diff)
backend: fix mem2reg & regalloc
they were broken, especially for unstructured control flow. most significant fix is to register allocator for temporaries that are used before the first definition in the source order, e.g.: @1: %x = add %y, 1 b @3 @2 %y = ... b @1 it's legal for %x to use %y there (assuming @2 dominates @1) but from the point of view of the register allocator %y is defined and freed and then used again, which broke things. the fix is to introduce phis for this situation: @1: %y.1 = phi @2 %y %x = add %y.1, 1 b @3 @2 %y = ... b @1 then regalloc phi handling code makes it work
Diffstat (limited to 'ir.c')
-rw-r--r--ir.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/ir.c b/ir.c
index 69cb1fa..79f9ebd 100644
--- a/ir.c
+++ b/ir.c
@@ -25,6 +25,7 @@ struct addr addrht[1 << 12];
static int naddrht;
struct xcon conht[1 << 12];
static int nconht;
+int visitmark;
void
irinit(struct function *fn)