shithub: scc

Download patch

ref: 32f13e84d1f68ada101e8a349c22388bd04a3d36
parent: 8bab7047ee0b8d7c786c84f6838d9fc64be579d5
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Nov 11 11:56:48 EST 2021

cc2/qbe: Don't load addresses generated

When an address is generated as part of a decay, or
as part of the & operator we do not have to generate
any code, because in that case we are only interested
in the memory location.

--- a/src/cmd/cc/cc2/cc2.h
+++ b/src/cmd/cc/cc2/cc2.h
@@ -13,6 +13,7 @@
 	INITF   =     1 << 7,  /* initializer flag */
 	ELLIPS  =     1 << 8,  /* vararg function */
 	ARRF    =     1 << 9,  /* array flag */
+	PTRF    =     1 << 10, /* pointer flag */
 };
 
 enum sclass {
--- a/src/cmd/cc/cc2/target/qbe/cgen.c
+++ b/src/cmd/cc/cc2/target/qbe/cgen.c
@@ -170,7 +170,7 @@
 	Node *new;
 	int flags = tp->flags;
 
-	if (flags & (AGGRF|FUNF|ARRF))
+	if (flags & (AGGRF|FUNF|ARRF|PTRF))
 		return np;
 
 	switch (tp->size) {
@@ -667,6 +667,7 @@
 	case OADDR:
 		l = lhs(l);
 		l->type = *tp;
+		l->type.flags |= PTRF;
 		return l;
 	case OFIELD:
 		return field(np, 0);