From e922403aa8658c95e1c7fd369f75ce508e5aea7b Mon Sep 17 00:00:00 2001 From: Dale Weiler Date: Fri, 30 Jan 2015 00:40:59 -0500 Subject: [PATCH 1/1] Don't allocate globals for constants that aren't read --- ir.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ir.c b/ir.c index 5a6229f..8d52898 100644 --- a/ir.c +++ b/ir.c @@ -3772,6 +3772,8 @@ static bool ir_builder_gen_global(ir_builder *self, ir_value *global, bool isloc { ir_value_code_setaddr(global, vec_size(self->code->globals)); if (global->hasvalue) { + if (global->cvq == CV_CONST && !vec_size(global->reads)) + return true; iptr = (int32_t*)&global->constval.ivec[0]; vec_push(self->code->globals, *iptr); } else { @@ -3787,7 +3789,10 @@ static bool ir_builder_gen_global(ir_builder *self, ir_value *global, bool isloc { ir_value_code_setaddr(global, vec_size(self->code->globals)); if (global->hasvalue) { - uint32_t load = code_genstring(self->code, global->constval.vstring); + uint32_t load; + if (global->cvq == CV_CONST && !vec_size(global->reads)) + return true; + load = code_genstring(self->code, global->constval.vstring); vec_push(self->code->globals, load); } else { vec_push(self->code->globals, 0); -- 2.39.2