Use ODR for canonical types construction in LTO

Jan Hubicka hubicka@ucw.cz
Wed Jun 19 13:28:00 GMT 2019


> Jason,
> I also wonder if something like this would make sense:
> 
> 	* decl.c (build_clobber_this): Use original basetype if they
> 	match.
> 
> Index: decl.c
> ===================================================================
> --- decl.c	(revision 272381)
> +++ decl.c	(working copy)
> @@ -15210,7 +15210,11 @@ build_clobber_this ()
>  
>    tree ctype = current_class_type;
>    if (!vbases)
> -    ctype = CLASSTYPE_AS_BASE (ctype);
> +    {
> +      if (!tree_int_cst_equal (TYPE_SIZE (ctype),
> +			       TYPE_SIZE (CLASSTYPE_AS_BASE (ctype))))
> +        ctype = CLASSTYPE_AS_BASE (ctype);
> +    }
>  
>    tree clobber = build_clobber (ctype);

I have lto-bootstrapped/regtested the aptch and it seems to work just
fine.  For tramp3d it reduces number of types:
[WPA] read 56122 SCCs of average size 1.127419
[WPA] 63273 tree bodies read in total
[WPA] tree SCC table: size 65521, 40469 elements, collision ratio:
1.141428
[WPA] tree SCC max chain length 12 (size 1)
[WPA] Compared 3603 SCCs, 657 collisions (0.182348)
[WPA] Merged 3488 SCCs
[WPA] Merged 3496 tree bodies
[WPA] Merged 1949 types
[WPA] 24104 types prevailed (31196 associated trees)
[WPA] GIMPLE canonical type table: size 16381, 412 elements, 2106
searches, 19 collisions (ratio: 0.009022)
[WPA] GIMPLE canonical type pointer-map: 412 elements, 3430 searches

to

[WPA] read 55182 SCCs of average size 1.098384
[WPA] 60611 tree bodies read in total
[WPA] tree SCC table: size 65521, 39444 elements, collision ratio:
1.127024
[WPA] tree SCC max chain length 12 (size 1)
[WPA] Compared 3603 SCCs, 657 collisions (0.182348)
[WPA] Merged 3488 SCCs
[WPA] Merged 3496 tree bodies
[WPA] Merged 1949 types
[WPA] 22908 types prevailed (28278 associated trees)
[WPA] GIMPLE canonical type table: size 16381, 405 elements, 1390
searches, 13 collisions (ratio: 0.009353)
[WPA] GIMPLE canonical type pointer-map: 405 elements, 1998 searches

since the number of GIMPLE canonical type hash searches roughly
corresponds to number of types in the LTO stream, it is down by 50%
that is nice.

Morever the patch improves TBAA oracle from:

Alias oracle query stats:
  refs_may_alias_p: 3021544 disambiguations, 3321141 queries
  ref_maybe_used_by_call_p: 7118 disambiguations, 3047138 queries
  call_may_clobber_ref_p: 817 disambiguations, 817 queries
  nonoverlapping_component_refs_p: 27 disambiguations, 63312 queries
  nonoverlapping_component_refs_of_decl_p: 19 disambiguations, 2192 queries
  aliasing_component_refs_p: 2050 disambiguations, 20312 queries
  TBAA oracle: 1419961 disambiguations 2917965 queries
               555158 are in alias set 0
               575113 queries asked about the same object
               0 queries asked about the same alias set
               0 access volatile
               253187 are dependent in the DAG
               114546 are aritificially in conflict with void *

PTA query stats:
  pt_solution_includes: 671982 disambiguations, 952515 queries
  pt_solutions_intersect: 97060 disambiguations, 437910 queries

to

Alias oracle query stats:
  refs_may_alias_p: 3243740 disambiguations, 3545965 queries
  ref_maybe_used_by_call_p: 6861 disambiguations, 3268658 queries
  call_may_clobber_ref_p: 817 disambiguations, 817 queries
  nonoverlapping_component_refs_p: 27 disambiguations, 64095 queries
  nonoverlapping_component_refs_of_decl_p: 19 disambiguations, 2192 queries
  aliasing_component_refs_p: 2058 disambiguations, 21010 queries
  TBAA oracle: 1488225 disambiguations 3022119 queries
               551266 are in alias set 0
               575109 queries asked about the same object
               0 queries asked about the same alias set
               0 access volatile
               290651 are dependent in the DAG
               116868 are aritificially in conflict with void *

PTA query stats:
  pt_solution_includes: 679953 disambiguations, 965286 queries
  pt_solutions_intersect: 97067 disambiguations, 437676 queries

This is bit inexpected, but I think it mostly comes from the fact that
same_type_for_tbaa currently returns -1 for the fake type and original
type. This disables good part of access path querries.

I also tested the patch setting TYPE_CANONICAL to be same between
original and the fake copy. It works but I have to disable type verifier
that wants match between TYPE_MODE and TYPE_SIZE.

Honza



More information about the Gcc-patches mailing list