summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--all.h2
-rw-r--r--amd64/isel.c4
-rw-r--r--util.c6
3 files changed, 8 insertions, 4 deletions
diff --git a/all.h b/all.h
index 7f843a9..4b9eb0e 100644
--- a/all.h
+++ b/all.h
@@ -433,7 +433,7 @@ int phicls(int, Tmp *);
 Ref newtmp(char *, int, Fn *);
 void chuse(Ref, int, Fn *);
 Ref getcon(int64_t, Fn *);
-void addcon(Con *, Con *);
+int addcon(Con *, Con *);
 void blit(Ref, uint, Ref, uint, Fn *);
 void dumpts(BSet *, Tmp *, FILE *);
 
diff --git a/amd64/isel.c b/amd64/isel.c
index e8a78f3..0b0a2df 100644
--- a/amd64/isel.c
+++ b/amd64/isel.c
@@ -512,7 +512,9 @@ amatch(Addr *a, Ref r, int n, ANum *ai, Fn *fn)
 	Ref al, ar;
 
 	if (rtype(r) == RCon) {
-		addcon(&a->offset, &fn->con[r.val]);
+		if (!addcon(&a->offset, &fn->con[r.val]))
+			err("unlikely sum of $%s and $%s",
+				str(a->offset.label), str(fn->con[r.val].label));
 		return 1;
 	}
 	assert(rtype(r) == RTmp);
diff --git a/util.c b/util.c
index 0123e27..a28176d 100644
--- a/util.c
+++ b/util.c
@@ -362,19 +362,21 @@ getcon(int64_t val, Fn *fn)
 	return CON(c);
 }
 
-void
+int
 addcon(Con *c0, Con *c1)
 {
 	if (c0->type == CUndef)
 		*c0 = *c1;
 	else {
 		if (c1->type == CAddr) {
-			assert(c0->type != CAddr && "adding two addresses");
+			if (c0->type == CAddr)
+				return 0;
 			c0->type = CAddr;
 			c0->label = c1->label;
 		}
 		c0->bits.i += c1->bits.i;
 	}
+	return 1;
 }
 
 void