tree-ssa-structalias.c (171826) | tree-ssa-structalias.c (220150) |
---|---|
1/* Tree based points-to analysis 2 Copyright (C) 2005, 2006 Free Software Foundation, Inc. 3 Contributed by Daniel Berlin <dberlin@dberlin.org> 4 5This file is part of GCC. 6 7GCC is free software; you can redistribute it and/or modify 8under the terms of the GNU General Public License as published by --- 4336 unchanged lines hidden (view full) --- 4345 4346 lhs.var = escaped_vars_id; 4347 lhs.type = SCALAR; 4348 lhs.offset = 0; 4349 4350 process_constraint (new_constraint (lhs, rhs)); 4351} 4352 | 1/* Tree based points-to analysis 2 Copyright (C) 2005, 2006 Free Software Foundation, Inc. 3 Contributed by Daniel Berlin <dberlin@dberlin.org> 4 5This file is part of GCC. 6 7GCC is free software; you can redistribute it and/or modify 8under the terms of the GNU General Public License as published by --- 4336 unchanged lines hidden (view full) --- 4345 4346 lhs.var = escaped_vars_id; 4347 lhs.type = SCALAR; 4348 lhs.offset = 0; 4349 4350 process_constraint (new_constraint (lhs, rhs)); 4351} 4352 |
4353/* Structure used to put solution bitmaps in a hashtable so they can 4354 be shared among variables with the same points-to set. */ 4355 4356typedef struct shared_bitmap_info 4357{ 4358 bitmap pt_vars; 4359 hashval_t hashcode; 4360} *shared_bitmap_info_t; 4361 4362static htab_t shared_bitmap_table; 4363 4364/* Hash function for a shared_bitmap_info_t */ 4365 4366static hashval_t 4367shared_bitmap_hash (const void *p) 4368{ 4369 const shared_bitmap_info_t bi = (shared_bitmap_info_t) p; 4370 return bi->hashcode; 4371} 4372 4373/* Equality function for two shared_bitmap_info_t's. */ 4374 4375static int 4376shared_bitmap_eq (const void *p1, const void *p2) 4377{ 4378 const shared_bitmap_info_t sbi1 = (shared_bitmap_info_t) p1; 4379 const shared_bitmap_info_t sbi2 = (shared_bitmap_info_t) p2; 4380 return bitmap_equal_p (sbi1->pt_vars, sbi2->pt_vars); 4381} 4382 4383/* Lookup a bitmap in the shared bitmap hashtable, and return an already 4384 existing instance if there is one, NULL otherwise. */ 4385 4386static bitmap 4387shared_bitmap_lookup (bitmap pt_vars) 4388{ 4389 void **slot; 4390 struct shared_bitmap_info sbi; 4391 4392 sbi.pt_vars = pt_vars; 4393 sbi.hashcode = bitmap_hash (pt_vars); 4394 4395 slot = htab_find_slot_with_hash (shared_bitmap_table, &sbi, 4396 sbi.hashcode, NO_INSERT); 4397 if (!slot) 4398 return NULL; 4399 else 4400 return ((shared_bitmap_info_t) *slot)->pt_vars; 4401} 4402 4403 4404/* Add a bitmap to the shared bitmap hashtable. */ 4405 4406static void 4407shared_bitmap_add (bitmap pt_vars) 4408{ 4409 void **slot; 4410 shared_bitmap_info_t sbi = XNEW (struct shared_bitmap_info); 4411 4412 sbi->pt_vars = pt_vars; 4413 sbi->hashcode = bitmap_hash (pt_vars); 4414 4415 slot = htab_find_slot_with_hash (shared_bitmap_table, sbi, 4416 sbi->hashcode, INSERT); 4417 gcc_assert (!*slot); 4418 *slot = (void *) sbi; 4419} 4420 4421 |
|
4353/* Set bits in INTO corresponding to the variable uids in solution set 4354 FROM, which came from variable PTR. 4355 For variables that are actually dereferenced, we also use type 4356 based alias analysis to prune the points-to sets. */ 4357 4358static void 4359set_uids_in_ptset (tree ptr, bitmap into, bitmap from) 4360{ --- 94 unchanged lines hidden (view full) --- 4455 || get_subvars_for_var (vi->decl) == NULL) 4456 return false; 4457 } 4458 else 4459 { 4460 struct ptr_info_def *pi = get_ptr_info (p); 4461 unsigned int i; 4462 bitmap_iterator bi; | 4422/* Set bits in INTO corresponding to the variable uids in solution set 4423 FROM, which came from variable PTR. 4424 For variables that are actually dereferenced, we also use type 4425 based alias analysis to prune the points-to sets. */ 4426 4427static void 4428set_uids_in_ptset (tree ptr, bitmap into, bitmap from) 4429{ --- 94 unchanged lines hidden (view full) --- 4524 || get_subvars_for_var (vi->decl) == NULL) 4525 return false; 4526 } 4527 else 4528 { 4529 struct ptr_info_def *pi = get_ptr_info (p); 4530 unsigned int i; 4531 bitmap_iterator bi; |
4463 | 4532 bitmap finished_solution; 4533 bitmap result; 4534 |
4464 /* This variable may have been collapsed, let's get the real 4465 variable. */ 4466 vi = get_varinfo (find (vi->id)); 4467 4468 /* Translate artificial variables into SSA_NAME_PTR_INFO 4469 attributes. */ 4470 EXECUTE_IF_SET_IN_BITMAP (vi->solution, 0, i, bi) 4471 { --- 15 unchanged lines hidden (view full) --- 4487 else if (vi->is_heap_var) 4488 pi->pt_global_mem = 1; 4489 } 4490 } 4491 4492 if (pi->pt_anything) 4493 return false; 4494 | 4535 /* This variable may have been collapsed, let's get the real 4536 variable. */ 4537 vi = get_varinfo (find (vi->id)); 4538 4539 /* Translate artificial variables into SSA_NAME_PTR_INFO 4540 attributes. */ 4541 EXECUTE_IF_SET_IN_BITMAP (vi->solution, 0, i, bi) 4542 { --- 15 unchanged lines hidden (view full) --- 4558 else if (vi->is_heap_var) 4559 pi->pt_global_mem = 1; 4560 } 4561 } 4562 4563 if (pi->pt_anything) 4564 return false; 4565 |
4495 if (!pi->pt_vars) 4496 pi->pt_vars = BITMAP_GGC_ALLOC (); | 4566 finished_solution = BITMAP_GGC_ALLOC (); 4567 set_uids_in_ptset (vi->decl, finished_solution, vi->solution); 4568 result = shared_bitmap_lookup (finished_solution); |
4497 | 4569 |
4498 set_uids_in_ptset (vi->decl, pi->pt_vars, vi->solution); | 4570 if (!result) 4571 { 4572 shared_bitmap_add (finished_solution); 4573 pi->pt_vars = finished_solution; 4574 } 4575 else 4576 { 4577 pi->pt_vars = result; 4578 bitmap_clear (finished_solution); 4579 } |
4499 4500 if (bitmap_empty_p (pi->pt_vars)) 4501 pi->pt_vars = NULL; 4502 4503 return true; 4504 } 4505 } 4506 --- 179 unchanged lines hidden (view full) --- 4686 sizeof (struct constraint), 30); 4687 variable_info_pool = create_alloc_pool ("Variable info pool", 4688 sizeof (struct variable_info), 30); 4689 constraints = VEC_alloc (constraint_t, heap, 8); 4690 varmap = VEC_alloc (varinfo_t, heap, 8); 4691 vi_for_tree = pointer_map_create (); 4692 4693 memset (&stats, 0, sizeof (stats)); | 4580 4581 if (bitmap_empty_p (pi->pt_vars)) 4582 pi->pt_vars = NULL; 4583 4584 return true; 4585 } 4586 } 4587 --- 179 unchanged lines hidden (view full) --- 4767 sizeof (struct constraint), 30); 4768 variable_info_pool = create_alloc_pool ("Variable info pool", 4769 sizeof (struct variable_info), 30); 4770 constraints = VEC_alloc (constraint_t, heap, 8); 4771 varmap = VEC_alloc (varinfo_t, heap, 8); 4772 vi_for_tree = pointer_map_create (); 4773 4774 memset (&stats, 0, sizeof (stats)); |
4775 shared_bitmap_table = htab_create (511, shared_bitmap_hash, 4776 shared_bitmap_eq, free); |
|
4694 init_base_vars (); 4695} 4696 4697/* Given a statement STMT, generate necessary constraints to 4698 escaped_vars for the escaping variables. */ 4699 4700static void 4701find_escape_constraints (tree stmt) --- 216 unchanged lines hidden (view full) --- 4918/* Delete created points-to sets. */ 4919 4920void 4921delete_points_to_sets (void) 4922{ 4923 varinfo_t v; 4924 int i; 4925 | 4777 init_base_vars (); 4778} 4779 4780/* Given a statement STMT, generate necessary constraints to 4781 escaped_vars for the escaping variables. */ 4782 4783static void 4784find_escape_constraints (tree stmt) --- 216 unchanged lines hidden (view full) --- 5001/* Delete created points-to sets. */ 5002 5003void 5004delete_points_to_sets (void) 5005{ 5006 varinfo_t v; 5007 int i; 5008 |
5009 htab_delete (shared_bitmap_table); |
|
4926 if (dump_file && (dump_flags & TDF_STATS)) 4927 fprintf (dump_file, "Points to sets created:%d\n", 4928 stats.points_to_sets_created); 4929 4930 pointer_map_destroy (vi_for_tree); 4931 bitmap_obstack_release (&pta_obstack); 4932 VEC_free (constraint_t, heap, constraints); 4933 --- 159 unchanged lines hidden --- | 5010 if (dump_file && (dump_flags & TDF_STATS)) 5011 fprintf (dump_file, "Points to sets created:%d\n", 5012 stats.points_to_sets_created); 5013 5014 pointer_map_destroy (vi_for_tree); 5015 bitmap_obstack_release (&pta_obstack); 5016 VEC_free (constraint_t, heap, constraints); 5017 --- 159 unchanged lines hidden --- |