Lines 334-340
struct stack_var
Link Here
|
334 |
static struct stack_var *stack_vars; |
334 |
static struct stack_var *stack_vars; |
335 |
static size_t stack_vars_alloc; |
335 |
static size_t stack_vars_alloc; |
336 |
static size_t stack_vars_num; |
336 |
static size_t stack_vars_num; |
337 |
static hash_map<tree, size_t> *decl_to_stack_part; |
337 |
typedef int_hash <unsigned int, -1U> uid_to_stack_part_hash; |
|
|
338 |
static hash_map<uid_to_stack_part_hash, size_t> *uid_to_stack_part; |
338 |
|
339 |
|
339 |
/* Conflict bitmaps go on this obstack. This allows us to destroy |
340 |
/* Conflict bitmaps go on this obstack. This allows us to destroy |
340 |
all of them in one big sweep. */ |
341 |
all of them in one big sweep. */ |
Lines 431-442
add_stack_var (tree decl)
Link Here
|
431 |
stack_vars |
432 |
stack_vars |
432 |
= XRESIZEVEC (struct stack_var, stack_vars, stack_vars_alloc); |
433 |
= XRESIZEVEC (struct stack_var, stack_vars, stack_vars_alloc); |
433 |
} |
434 |
} |
434 |
if (!decl_to_stack_part) |
|
|
435 |
decl_to_stack_part = new hash_map<tree, size_t>; |
436 |
|
435 |
|
437 |
v = &stack_vars[stack_vars_num]; |
436 |
v = &stack_vars[stack_vars_num]; |
438 |
decl_to_stack_part->put (decl, stack_vars_num); |
|
|
439 |
|
440 |
v->decl = decl; |
437 |
v->decl = decl; |
441 |
tree size = TREE_CODE (decl) == SSA_NAME |
438 |
tree size = TREE_CODE (decl) == SSA_NAME |
442 |
? TYPE_SIZE_UNIT (TREE_TYPE (decl)) |
439 |
? TYPE_SIZE_UNIT (TREE_TYPE (decl)) |
Lines 512-518
visit_op (gimple *, tree op, tree, void
Link Here
|
512 |
&& DECL_P (op) |
509 |
&& DECL_P (op) |
513 |
&& DECL_RTL_IF_SET (op) == pc_rtx) |
510 |
&& DECL_RTL_IF_SET (op) == pc_rtx) |
514 |
{ |
511 |
{ |
515 |
size_t *v = decl_to_stack_part->get (op); |
512 |
size_t *v = uid_to_stack_part->get (DECL_UID (op)); |
516 |
if (v) |
513 |
if (v) |
517 |
bitmap_set_bit (active, *v); |
514 |
bitmap_set_bit (active, *v); |
518 |
} |
515 |
} |
Lines 532-538
visit_conflict (gimple *, tree op, tree,
Link Here
|
532 |
&& DECL_P (op) |
529 |
&& DECL_P (op) |
533 |
&& DECL_RTL_IF_SET (op) == pc_rtx) |
530 |
&& DECL_RTL_IF_SET (op) == pc_rtx) |
534 |
{ |
531 |
{ |
535 |
size_t *v = decl_to_stack_part->get (op); |
532 |
size_t *v = uid_to_stack_part->get (DECL_UID (op)); |
536 |
if (v && bitmap_set_bit (active, *v)) |
533 |
if (v && bitmap_set_bit (active, *v)) |
537 |
{ |
534 |
{ |
538 |
size_t num = *v; |
535 |
size_t num = *v; |
Lines 583-589
add_scope_conflicts_1 (basic_block bb, b
Link Here
|
583 |
if (!VAR_P (lhs)) |
580 |
if (!VAR_P (lhs)) |
584 |
continue; |
581 |
continue; |
585 |
if (DECL_RTL_IF_SET (lhs) == pc_rtx |
582 |
if (DECL_RTL_IF_SET (lhs) == pc_rtx |
586 |
&& (v = decl_to_stack_part->get (lhs))) |
583 |
&& (v = uid_to_stack_part->get (DECL_UID (lhs)))) |
587 |
bitmap_clear_bit (work, *v); |
584 |
bitmap_clear_bit (work, *v); |
588 |
} |
585 |
} |
589 |
else if (!is_gimple_debug (stmt)) |
586 |
else if (!is_gimple_debug (stmt)) |
Lines 609-614
add_scope_conflicts_1 (basic_block bb, b
Link Here
|
609 |
visit = visit_conflict; |
606 |
visit = visit_conflict; |
610 |
} |
607 |
} |
611 |
walk_stmt_load_store_addr_ops (stmt, work, visit, visit, visit); |
608 |
walk_stmt_load_store_addr_ops (stmt, work, visit, visit, visit); |
|
|
609 |
|
610 |
/* For pointer SSA_NAMEs used in the stmt, also consider variables |
611 |
from points-to set, see PR90348. */ |
612 |
ssa_op_iter oi; |
613 |
use_operand_p use_p; |
614 |
FOR_EACH_SSA_USE_OPERAND (use_p, stmt, oi, SSA_OP_USE) |
615 |
{ |
616 |
tree op = USE_FROM_PTR (use_p); |
617 |
if (TREE_CODE (op) == SSA_NAME |
618 |
&& POINTER_TYPE_P (TREE_TYPE (op)) |
619 |
&& SSA_NAME_PTR_INFO (op) |
620 |
&& SSA_NAME_PTR_INFO (op)->pt.vars) |
621 |
{ |
622 |
bitmap_iterator bi; |
623 |
unsigned i; |
624 |
|
625 |
EXECUTE_IF_SET_IN_BITMAP (SSA_NAME_PTR_INFO (op)->pt.vars, |
626 |
0, i, bi) |
627 |
if (size_t *v = uid_to_stack_part->get (i)) |
628 |
if (bitmap_set_bit (work, *v) && for_conflict) |
629 |
{ |
630 |
size_t num = *v; |
631 |
bitmap_iterator bi2; |
632 |
unsigned j; |
633 |
gcc_assert (num < stack_vars_num); |
634 |
EXECUTE_IF_SET_IN_BITMAP (work, 0, j, bi2) |
635 |
add_stack_var_conflict (num, j); |
636 |
} |
637 |
} |
638 |
} |
612 |
} |
639 |
} |
613 |
} |
640 |
} |
614 |
} |
641 |
} |
Lines 641-646
add_scope_conflicts (void)
Link Here
|
641 |
rpo = XNEWVEC (int, last_basic_block_for_fn (cfun)); |
668 |
rpo = XNEWVEC (int, last_basic_block_for_fn (cfun)); |
642 |
n_bbs = pre_and_rev_post_order_compute (NULL, rpo, false); |
669 |
n_bbs = pre_and_rev_post_order_compute (NULL, rpo, false); |
643 |
|
670 |
|
|
|
671 |
uid_to_stack_part |
672 |
= new hash_map<uid_to_stack_part_hash, size_t> (stack_vars_num); |
673 |
for (size_t i = 0; i < stack_vars_num; ++i) |
674 |
if (DECL_RTL_IF_SET (stack_vars[i].decl) == pc_rtx) |
675 |
uid_to_stack_part->put (DECL_UID (stack_vars[i].decl), i); |
676 |
|
644 |
changed = true; |
677 |
changed = true; |
645 |
while (changed) |
678 |
while (changed) |
646 |
{ |
679 |
{ |
Lines 660-665
add_scope_conflicts (void)
Link Here
|
660 |
FOR_EACH_BB_FN (bb, cfun) |
693 |
FOR_EACH_BB_FN (bb, cfun) |
661 |
add_scope_conflicts_1 (bb, work, true); |
694 |
add_scope_conflicts_1 (bb, work, true); |
662 |
|
695 |
|
|
|
696 |
delete uid_to_stack_part; |
697 |
uid_to_stack_part = NULL; |
663 |
free (rpo); |
698 |
free (rpo); |
664 |
BITMAP_FREE (work); |
699 |
BITMAP_FREE (work); |
665 |
FOR_ALL_BB_FN (bb, cfun) |
700 |
FOR_ALL_BB_FN (bb, cfun) |
Lines 1925-1933
init_vars_expansion (void)
Link Here
|
1925 |
/* Conflict bitmaps, and a few related temporary bitmaps, go here. */ |
1960 |
/* Conflict bitmaps, and a few related temporary bitmaps, go here. */ |
1926 |
bitmap_obstack_initialize (&stack_var_bitmap_obstack); |
1961 |
bitmap_obstack_initialize (&stack_var_bitmap_obstack); |
1927 |
|
1962 |
|
1928 |
/* A map from decl to stack partition. */ |
|
|
1929 |
decl_to_stack_part = new hash_map<tree, size_t>; |
1930 |
|
1931 |
/* Initialize local stack smashing state. */ |
1963 |
/* Initialize local stack smashing state. */ |
1932 |
has_protected_decls = false; |
1964 |
has_protected_decls = false; |
1933 |
has_short_buffer = false; |
1965 |
has_short_buffer = false; |
Lines 1945-1952
fini_vars_expansion (void)
Link Here
|
1945 |
stack_vars = NULL; |
1977 |
stack_vars = NULL; |
1946 |
stack_vars_sorted = NULL; |
1978 |
stack_vars_sorted = NULL; |
1947 |
stack_vars_alloc = stack_vars_num = 0; |
1979 |
stack_vars_alloc = stack_vars_num = 0; |
1948 |
delete decl_to_stack_part; |
|
|
1949 |
decl_to_stack_part = NULL; |
1950 |
} |
1980 |
} |
1951 |
|
1981 |
|
1952 |
/* Make a fair guess for the size of the stack frame of the function |
1982 |
/* Make a fair guess for the size of the stack frame of the function |