- add missing initialization of have_const_functions
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Tue, 23 Sep 2008 17:13:40 +0000 (17:13 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Tue, 23 Sep 2008 17:13:40 +0000 (17:13 +0000)
[r22214]

ast2firm.c
driver/firm_opt.c
main.c

index 6c47533..1c06786 100644 (file)
@@ -64,6 +64,8 @@ static int             inner_function_idx;
 static ir_node        *ijmp_list;
 static bool            constant_folding;
 
+extern bool            have_const_functions;
+
 static const declaration_t *current_function_decl;
 static ir_node             *current_function_name;
 static ir_node             *current_funcsig;
@@ -1049,6 +1051,7 @@ static void handle_gnu_attributes_ent(ir_entity *ent, declaration_t *decl)
        }
        if (decl->modifiers & DM_CONST) {
                set_entity_additional_property(ent, mtp_property_const);
+               have_const_functions = true;
        }
        if (decl->modifiers & DM_USED) {
                /* TRUE if the declaration includes the GNU
index ed28ec9..ee3f580 100644 (file)
@@ -303,7 +303,7 @@ static int firm_const_exists;
 
 static void do_optimize_funccalls(void)
 {
-       optimize_funccalls(true, NULL);
+       optimize_funccalls(firm_const_exists, NULL);
 }
 
 static void do_gcse(ir_graph *irg)
diff --git a/main.c b/main.c
index d75333d..1dd4976 100644 (file)
--- a/main.c
+++ b/main.c
@@ -114,6 +114,9 @@ bool strict_mode = false;
 /** use builtins for some libc functions */
 bool use_builtins = false;
 
+/** we have extern function with const attribute. */
+bool have_const_functions = false;
+
 /* to switch on printing of implicit casts */
 extern bool print_implicit_casts;
 
@@ -1131,7 +1134,7 @@ int main(int argc, char **argv)
                        }
 
                        gen_firm_finish(asm_out, filename, /*c_mode=*/1,
-                                       /*firm_const_exists=*/0);
+                                       have_const_functions);
                        if (asm_out != out) {
                                fclose(asm_out);
                        }