From 76b0eb0cb7cd3c22e6c8e9ed0ff5278da7fa48be Mon Sep 17 00:00:00 2001 From: "Wolfgang (Blub) Bumiller" Date: Thu, 23 Aug 2012 18:32:11 +0200 Subject: [PATCH] Don't add DEF_SAVEGLOBAL for locals actually... --- ir.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/ir.c b/ir.c index 0313fd9..cb97b29 100644 --- a/ir.c +++ b/ir.c @@ -2231,7 +2231,7 @@ static bool ir_block_life_propagate(ir_block *self, ir_block *prev, bool *change * * Breaking conventions is annoying... */ -static bool ir_builder_gen_global(ir_builder *self, ir_value *global); +static bool ir_builder_gen_global(ir_builder *self, ir_value *global, bool islocal); static bool gen_global_field(ir_value *global) { @@ -2576,7 +2576,7 @@ static bool gen_global_function(ir_builder *ir, ir_value *global) local_var_end = fun.firstlocal; for (i = 0; i < irfun->locals_count; ++i) { - if (!ir_builder_gen_global(ir, irfun->locals[i])) { + if (!ir_builder_gen_global(ir, irfun->locals[i], true)) { irerror(irfun->locals[i]->context, "Failed to generate local %s", irfun->locals[i]->name); return false; } @@ -2639,7 +2639,7 @@ static bool gen_global_function_code(ir_builder *ir, ir_value *global) return true; } -static bool ir_builder_gen_global(ir_builder *self, ir_value *global) +static bool ir_builder_gen_global(ir_builder *self, ir_value *global, bool islocal) { size_t i; int32_t *iptr; @@ -2691,7 +2691,8 @@ static bool ir_builder_gen_global(ir_builder *self, ir_value *global) ir_value_code_setaddr(global, code_globals_add(*iptr)); } else { ir_value_code_setaddr(global, code_globals_add(0)); - def.type |= DEF_SAVEGLOBAL; + if (!islocal) + def.type |= DEF_SAVEGLOBAL; } if (code_defs_add(def) < 0) return false; @@ -2704,7 +2705,8 @@ static bool ir_builder_gen_global(ir_builder *self, ir_value *global) ir_value_code_setaddr(global, code_globals_add(code_cachedstring(global->constval.vstring))); else { ir_value_code_setaddr(global, code_globals_add(0)); - def.type |= DEF_SAVEGLOBAL; + if (!islocal) + def.type |= DEF_SAVEGLOBAL; } if (code_defs_add(def) < 0) return false; @@ -2732,7 +2734,8 @@ static bool ir_builder_gen_global(ir_builder *self, ir_value *global) if (code_globals_add(0) < 0) return false; } - def.type |= DEF_SAVEGLOBAL; + if (!islocal) + def.type |= DEF_SAVEGLOBAL; } if (code_defs_add(def) < 0) @@ -2749,7 +2752,8 @@ static bool ir_builder_gen_global(ir_builder *self, ir_value *global) code_globals_add(code_functions_elements); if (!gen_global_function(self, global)) return false; - def.type |= DEF_SAVEGLOBAL; + if (!islocal) + def.type |= DEF_SAVEGLOBAL; } if (code_defs_add(def) < 0) return false; @@ -2845,7 +2849,7 @@ bool ir_builder_generate(ir_builder *self, const char *filename) for (i = 0; i < self->globals_count; ++i) { - if (!ir_builder_gen_global(self, self->globals[i])) { + if (!ir_builder_gen_global(self, self->globals[i], false)) { return false; } } -- 2.39.2