From 48514ba2f3dd432371ed3325a46108ecd4f9bb19 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 7 Mar 2020 01:30:36 +0900 Subject: [PATCH] [qfcc] Create alias def for defs accessed via pointer This the fixes the incorrect flow analysis caused by the def being seen to have the wrong size (structure field of structure def seen through a constant pointer). Fixes the ICE, but the pointer constant is broken somewhere in dags, presumably. --- tools/qfcc/source/flow.c | 4 +++- tools/qfcc/source/statements.c | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/qfcc/source/flow.c b/tools/qfcc/source/flow.c index 995aa5b7d..aa05733e8 100644 --- a/tools/qfcc/source/flow.c +++ b/tools/qfcc/source/flow.c @@ -859,8 +859,10 @@ flow_analyze_statement (statement_t *s, set_t *use, set_t *def, set_t *kill, && s->opc->o.value->lltype == ev_pointer && s->opc->o.value->v.pointer.def) { operand_t *op; + def_t *alias; ex_pointer_t *ptr = &s->opc->o.value->v.pointer; - op = def_operand (ptr->def, ptr->type); + alias = alias_def (ptr->def, ptr->type, ptr->val); + op = def_operand (alias, ptr->type); flow_add_op_var (def, op); if (operands) operands[0] = op; diff --git a/tools/qfcc/source/statements.c b/tools/qfcc/source/statements.c index 239c11f49..e29cedaa4 100644 --- a/tools/qfcc/source/statements.c +++ b/tools/qfcc/source/statements.c @@ -103,7 +103,13 @@ operand_string (operand_t *op) op->o.value->v.quaternion_val[2], op->o.value->v.quaternion_val[3]); case ev_pointer: - return va ("ptr %d", op->o.value->v.pointer.val); + if (op->o.value->v.pointer.def) { + return va ("ptr %s+%d", + op->o.value->v.pointer.def->name, + op->o.value->v.pointer.val); + } else { + return va ("ptr %d", op->o.value->v.pointer.val); + } case ev_field: return va ("field %d", op->o.value->v.pointer.val); case ev_entity: