This puts checking code into place that we do not put globals into referenced-vars (nor allocate var-annotations for them). It also fixes remaining cases in mudflap and matrix-reorg.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2012-05-29 Richard Guenther <rguent...@suse.de> * tree-dfa.c (find_vars_r): Do not call add_referenced_vars for globals. (add_referenced_var_1): Re-organize. Assert we are not called for globals. (remove_referenced_var): Likewise. * varpool.c (add_new_static_var): Use create_tmp_var_raw. * tree-mudflap.c (execute_mudflap_function_ops): Do not call add_referenced_var on globals. * matrix-reorg.c (transform_access_sites): Likewise. Index: gcc/tree-dfa.c =================================================================== *** gcc/tree-dfa.c (revision 187830) --- gcc/tree-dfa.c (working copy) *************** find_vars_r (tree *tp, int *walk_subtree *** 430,436 **** /* If T is a regular variable that the optimizers are interested in, add it to the list of variables. */ ! else if (SSA_VAR_P (*tp)) add_referenced_var_1 (*tp, fn); /* Type, _DECL and constant nodes have no interesting children. --- 430,439 ---- /* If T is a regular variable that the optimizers are interested in, add it to the list of variables. */ ! else if ((TREE_CODE (*tp) == VAR_DECL ! && !is_global_var (*tp)) ! || TREE_CODE (*tp) == PARM_DECL ! || TREE_CODE (*tp) == RESULT_DECL) add_referenced_var_1 (*tp, fn); /* Type, _DECL and constant nodes have no interesting children. *************** add_referenced_var_1 (tree var, struct f *** 560,581 **** || TREE_CODE (var) == PARM_DECL || TREE_CODE (var) == RESULT_DECL); ! if (!(TREE_CODE (var) == VAR_DECL ! && VAR_DECL_IS_VIRTUAL_OPERAND (var)) ! && is_global_var (var)) ! return false; ! if (!*DECL_VAR_ANN_PTR (var)) ! *DECL_VAR_ANN_PTR (var) = ggc_alloc_cleared_var_ann_d (); ! ! /* Insert VAR into the referenced_vars hash table if it isn't present. */ if (referenced_var_check_and_insert (var, fn)) ! return true; return false; } ! /* Remove VAR from the list. */ void remove_referenced_var (tree var) --- 563,586 ---- || TREE_CODE (var) == PARM_DECL || TREE_CODE (var) == RESULT_DECL); ! gcc_checking_assert ((TREE_CODE (var) == VAR_DECL ! && VAR_DECL_IS_VIRTUAL_OPERAND (var)) ! || !is_global_var (var)); ! /* Insert VAR into the referenced_vars hash table if it isn't present ! and allocate its var-annotation. */ if (referenced_var_check_and_insert (var, fn)) ! { ! gcc_checking_assert (!*DECL_VAR_ANN_PTR (var)); ! *DECL_VAR_ANN_PTR (var) = ggc_alloc_cleared_var_ann_d (); ! return true; ! } return false; } ! /* Remove VAR from the list of referenced variables and clear its ! var-annotation. */ void remove_referenced_var (tree var) *************** remove_referenced_var (tree var) *** 585,598 **** void **loc; unsigned int uid = DECL_UID (var); ! /* Preserve var_anns of globals. */ ! if (!is_global_var (var) ! && (v_ann = var_ann (var))) ! { ! ggc_free (v_ann); ! *DECL_VAR_ANN_PTR (var) = NULL; ! } ! gcc_assert (DECL_P (var)); in.uid = uid; loc = htab_find_slot_with_hash (gimple_referenced_vars (cfun), &in, uid, NO_INSERT); --- 590,605 ---- void **loc; unsigned int uid = DECL_UID (var); ! gcc_checking_assert (TREE_CODE (var) == VAR_DECL ! || TREE_CODE (var) == PARM_DECL ! || TREE_CODE (var) == RESULT_DECL); ! ! gcc_checking_assert (!is_global_var (var)); ! ! v_ann = var_ann (var); ! ggc_free (v_ann); ! *DECL_VAR_ANN_PTR (var) = NULL; ! in.uid = uid; loc = htab_find_slot_with_hash (gimple_referenced_vars (cfun), &in, uid, NO_INSERT); Index: gcc/varpool.c =================================================================== *** gcc/varpool.c (revision 187830) --- gcc/varpool.c (working copy) *************** add_new_static_var (tree type) *** 449,455 **** tree new_decl; struct varpool_node *new_node; ! new_decl = create_tmp_var (type, NULL); DECL_NAME (new_decl) = create_tmp_var_name (NULL); TREE_READONLY (new_decl) = 0; TREE_STATIC (new_decl) = 1; --- 449,455 ---- tree new_decl; struct varpool_node *new_node; ! new_decl = create_tmp_var_raw (type, NULL); DECL_NAME (new_decl) = create_tmp_var_name (NULL); TREE_READONLY (new_decl) = 0; TREE_STATIC (new_decl) = 1; Index: gcc/tree-mudflap.c =================================================================== *** gcc/tree-mudflap.c (revision 187830) --- gcc/tree-mudflap.c (working copy) *************** execute_mudflap_function_ops (void) *** 427,436 **** push_gimplify_context (&gctx); - add_referenced_var (mf_cache_array_decl); - add_referenced_var (mf_cache_shift_decl); - add_referenced_var (mf_cache_mask_decl); - /* In multithreaded mode, don't cache the lookup cache parameters. */ if (! flag_mudflap_threads) mf_decl_cache_locals (); --- 427,432 ---- Index: gcc/matrix-reorg.c =================================================================== *** gcc/matrix-reorg.c (revision 187830) --- gcc/matrix-reorg.c (working copy) *************** transform_access_sites (void **slot, voi *** 1914,1920 **** num_elements = fold_build2 (MULT_EXPR, sizetype, fold_convert (sizetype, acc_info->index), fold_convert (sizetype, d_size)); - add_referenced_var (d_size); gsi = gsi_for_stmt (acc_info->stmt); tmp1 = force_gimple_operand_gsi (&gsi, num_elements, true, NULL, true, GSI_SAME_STMT); --- 1914,1919 ----