static void parse_ssa_operands (gimple stmt) { enum gimple_code code = gimple_code (stmt); if (code == GIMPLE_ASM) get_asm_expr_operands (stmt); else if (is_gimple_debug (stmt)) { if (gimple_debug_bind_p (stmt) && gimple_debug_bind_has_value_p (stmt)) get_expr_operands (stmt, gimple_debug_bind_get_value_ptr (stmt), opf_use | opf_no_vops); } else { size_t i, start = 0; if (code == GIMPLE_ASSIGN || code == GIMPLE_CALL) { get_expr_operands (stmt, gimple_op_ptr (stmt, 0), opf_def); start = 1; } for (i = start; i < gimple_num_ops (stmt); i++) get_expr_operands (stmt, gimple_op_ptr (stmt, i), opf_use); /* Add call-clobbered operands, if needed. */ if (code == GIMPLE_CALL) maybe_add_call_vops (stmt); if (code == GIMPLE_RETURN) append_vuse (gimple_vop (cfun)); } }
static tree scan_function (tree *tp, int *walk_subtrees, void *data) { struct cgraph_node *fn = data; tree t = *tp; funct_state local = get_function_state (fn); switch (TREE_CODE (t)) { case VAR_DECL: if (DECL_INITIAL (t)) walk_tree (&DECL_INITIAL (t), scan_function, fn, visited_nodes); *walk_subtrees = 0; break; case MODIFY_EXPR: { /* First look on the lhs and see what variable is stored to */ tree lhs = TREE_OPERAND (t, 0); tree rhs = TREE_OPERAND (t, 1); check_lhs_var (local, lhs); /* For the purposes of figuring out what the cast affects */ /* Next check the operands on the rhs to see if they are ok. */ switch (TREE_CODE_CLASS (TREE_CODE (rhs))) { case tcc_binary: { tree op0 = TREE_OPERAND (rhs, 0); tree op1 = TREE_OPERAND (rhs, 1); check_rhs_var (local, op0); check_rhs_var (local, op1); } break; case tcc_unary: { tree op0 = TREE_OPERAND (rhs, 0); check_rhs_var (local, op0); } break; case tcc_reference: check_rhs_var (local, rhs); break; case tcc_declaration: check_rhs_var (local, rhs); break; case tcc_expression: switch (TREE_CODE (rhs)) { case ADDR_EXPR: check_rhs_var (local, rhs); break; case CALL_EXPR: check_call (local, rhs); break; default: break; } break; default: break; } *walk_subtrees = 0; } break; case ADDR_EXPR: /* This case is here to find addresses on rhs of constructors in decl_initial of static variables. */ check_rhs_var (local, t); *walk_subtrees = 0; break; case LABEL_EXPR: if (DECL_NONLOCAL (TREE_OPERAND (t, 0))) /* Target of long jump. */ local->pure_const_state = IPA_NEITHER; break; case CALL_EXPR: check_call (local, t); *walk_subtrees = 0; break; case ASM_EXPR: get_asm_expr_operands (local, t); *walk_subtrees = 0; break; default: break; } return NULL; }
static tree scan_for_static_refs (tree *tp, int *walk_subtrees, void *data) { struct cgraph_node *fn = (struct cgraph_node *) data; tree t = *tp; ipa_reference_local_vars_info_t local = NULL; if (fn) local = get_reference_vars_info_from_cgraph (fn)->local; switch (TREE_CODE (t)) { case VAR_DECL: if (DECL_INITIAL (t)) walk_tree (&DECL_INITIAL (t), scan_for_static_refs, fn, visited_nodes); *walk_subtrees = 0; break; case GIMPLE_MODIFY_STMT: { /* First look on the lhs and see what variable is stored to */ tree lhs = GIMPLE_STMT_OPERAND (t, 0); tree rhs = GIMPLE_STMT_OPERAND (t, 1); check_lhs_var (local, lhs); /* For the purposes of figuring out what the cast affects */ /* Next check the operands on the rhs to see if they are ok. */ switch (TREE_CODE_CLASS (TREE_CODE (rhs))) { case tcc_binary: case tcc_comparison: { tree op0 = TREE_OPERAND (rhs, 0); tree op1 = TREE_OPERAND (rhs, 1); check_rhs_var (local, op0); check_rhs_var (local, op1); } break; case tcc_unary: { tree op0 = TREE_OPERAND (rhs, 0); check_rhs_var (local, op0); } break; case tcc_reference: check_rhs_var (local, rhs); break; case tcc_declaration: check_rhs_var (local, rhs); break; case tcc_expression: switch (TREE_CODE (rhs)) { case ADDR_EXPR: check_rhs_var (local, rhs); break; default: break; } break; case tcc_vl_exp: switch (TREE_CODE (rhs)) { case CALL_EXPR: check_call (local, rhs); break; default: break; } break; default: break; } *walk_subtrees = 0; } break; case ADDR_EXPR: /* This case is here to find addresses on rhs of constructors in decl_initial of static variables. */ check_rhs_var (local, t); *walk_subtrees = 0; break; case LABEL_EXPR: if (DECL_NONLOCAL (TREE_OPERAND (t, 0))) { /* Target of long jump. */ local->calls_read_all = true; local->calls_write_all = true; } break; case CALL_EXPR: check_call (local, t); *walk_subtrees = 0; break; case ASM_EXPR: get_asm_expr_operands (local, t); *walk_subtrees = 0; break; default: break; } return NULL; }