commit 37d7c9d148c70a2fc1bdae051b874e0afd911791
parent a358fdfe767eae0b94100246316faf62d354cc43
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Thu, 11 Nov 2021 16:56:48 +0100
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.
Diffstat:
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/cmd/cc/cc2/cc2.h b/src/cmd/cc/cc2/cc2.h
@@ -13,6 +13,7 @@ enum tflags {
INITF = 1 << 7, /* initializer flag */
ELLIPS = 1 << 8, /* vararg function */
ARRF = 1 << 9, /* array flag */
+ PTRF = 1 << 10, /* pointer flag */
};
enum sclass {
diff --git a/src/cmd/cc/cc2/target/qbe/cgen.c b/src/cmd/cc/cc2/target/qbe/cgen.c
@@ -170,7 +170,7 @@ load(Type *tp, Node *np)
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 @@ rhs(Node *np)
case OADDR:
l = lhs(l);
l->type = *tp;
+ l->type.flags |= PTRF;
return l;
case OFIELD:
return field(np, 0);