Sei sulla pagina 1di 32

The present and future of IPA-CP and related

analyses
Martin Jambor
SUSE Labs
July 20, 2014
IPA-CP

IPA pass

LTO capable

Cloning

Analysis also used for inlining

Indirect inlining (inlining of callbacks)

Providing call context for estimating protability


Propagation of values within aggregates
struct behavior_description
{
unsigned block_size;
void (
*
init)(context
*
ctx, element
*
e);
void (
*
copy)(context
*
ctx, element
*
dst, element
*
src);
void (
*
deinit)(context
*
ctx, element
*
e);
};
...
computation (&description, data);
Propagation of values within Fortran arrays
struct array_descriptor
{
void
*
data;
int ofset;
int dtype;
struct descriptor_dimension
{
int stride, lbound, ubound;
} dim[2];
};
Propagate everywhere interproceduraly
1
2 3 5
6 7 8
4
Aggregate jump function construction
struct behavior_description
{
unsigned block_size;
void (
*
init)(context
*
ctx, element
*
e);
void (
*
copy)(context
*
ctx, element
*
dst, element
*
src);
void (
*
deinit)(context
*
ctx, element
*
e);
};
...
description.block_size = 256;
description.init = my_init;
description.copy = my_copy;
description.deinit = my_deinit;
computation (&description, data);
Aggregate jump function construction
description.block_size = 256;
descrption.init = my_init;
description.copy = my_copy;
description.deinit = my_deinit;
computation (&description, data);
Aggregate jump function construction
description.block_size = 256;
descrption.init = my_init;
description.copy = my_copy;
description.deinit = my_deinit;
computation (&description, data);
foo ();
Aggregate information propagation
1
2 3 5
6 7 8
4
Standard IPA division
1. Intra-procedural analysis or summary building

See if data escapes (or does something other potentially


dangerous)

If not, assume it does not and create jump functions


optimistically

...but mark such speculations.

See how references in different functions relate to each


other.
2. Inter-procedural analysis on summaries

Spread escapes over call graph

Invalidate speculations for escaped data

Store for IPA-CP transformation phase.

Perhaps also for later use by AA?


Standard IPA division
1. Intra-procedural analysis or summary building

See if data escapes (or does something other potentially


dangerous)

If not, assume it does not and create jump functions


optimistically

...but mark such speculations.

See how references in different functions relate to each


other.
2. Inter-procedural analysis on summaries

Spread escapes over call graph

Invalidate speculations for escaped data

Store for IPA-CP transformation phase.

Perhaps also for later use by AA?


Summary building - escapes
void example (data_p data)
{
description_t description;
description.copy = &my_copy;
if (foo ())
bar ();
escape (&description, data);
another_use (&description, data);
}
void escape (description_t *description,
data_p data)
{
global.current_description = description;
compute_something_using_global (data);
}
Summary building - escapes
void example (data_p data)
{
description_t description;
description.copy = &my_copy;
if (foo ())
bar ();
escape (&description, data);
another_use (&description, data);
}
void escape (description_t *description,
data_p data)
{
global.current_description = description;
compute_something_using_global (data);
}
Summary building - escapes
void example (data_p data)
{
description_t description;
description.copy = &my_copy;
if (foo ())
bar ();
escape (&description, data);
another_use (&description, data);
}
void escape (description_t *description,
data_p data)
{
global.current_description = description;
compute_something_using_global (data);
}
Summary building - escapes
void example (data_p data)
{
description_t *description = malloc();
description->copy = &my_copy;
if (foo ())
bar ();
escape (description, data);
another_use (description, data);
free (description);
}
void escape (description_t *description,
data_p data)
{
global.current_description = description;
compute_something_using_global (data);
}
Summary building - escapes
void example (data_p data)
{
bigger_description_t *description = malloc();
description->small.copy = &my_copy;
if (foo ())
bar ();
escape (&description->small, data);
another_use (description, data);
free (description);
}
void escape (description_t *description,
data_p data)
{
global.current_description = description;
compute_something_using_global (data);
}
Propagating escapes
b
d c
e f
g
j
h
i
a
Reference escaped in
a callee, can have
unknown aliases.
A caller allowed the
reference to escape, there
may be hidden references.
No escaped
references, data
cannot have
aliases.
A caller might
have passed
the reference
to a function
where it escapes
and called
these
functions
afterwards.
There may be unknown
aliases.
Summaries of values
description.block_size = 128;
description.copy = my_copy;
description.init = my_init;
description.deinit = my_deinit;
foo ();
compute (&description, data);

Modication ag.
Summaries of values
description.block_size = 128;
description.copy = my_copy;
description.init = my_init;
description.deinit = my_deinit;
early_use(&description, data);
foo ();
compute (&description, data);

Modication ag.
Summaries of values
description.block_size = 128;
description.copy = my_copy;
description.init = my_init;
description.deinit = my_deinit;
early_use(&description, data);
foo ();
compute (&description, data);

Modication ag.
Results
| Test | Params | Noescape | % |
|--------------------+--------+----------+-------+
| Tramp 3D | 6344 | 1019 | 16.06 |
| bzip | 194 | 28 | 14.43 |
| hmmer | 643 | 71 | 11.04 |
| libquantum | 187 | 48 | 25.67 |
| astar | 217 | 28 | 12.90 |
| bwaves | 74 | 35 | 47.30 |
| gamess | 26059 | 3693 | 14.17 |
| zeusmp | 284 | 31 | 10.92 |
| calculix | 6260 | 1109 | 17.72 |
| GemsFDTD | 289 | 41 | 14.19 |
| tonto | 7255 | 1361 | 18.76 |
| lbm | 27 | 4 | 14.81 |
| wrf | 14212 | 4375 | 30.78 |
| ac.f90 | 21 | 14 | 66.67 |
| aermod.f90 | 600 | 134 | 22.33 |
| air.f90 | 85 | 41 | 48.24 |
| capacita.f90 | 42 | 18 | 42.86 |
Results (continued)
| Test | Params | Noescape | % |
|--------------------+--------+----------+-------+
| FF libxul.so | 462725 | 10422 | 2.25 |
| gcc | 10725 | 179 | 1.67 |
| xalancbmk | 28861 | 737 | 2.55 |
Problems, still missing things

Individual clobbers.

For Fotran, fancy aggregate jump functions.

delete operator

Probably more...
Problems, still missing things

Individual clobbers.

For Fotran, fancy aggregate jump functions.

delete operator

Probably more...
Propagation of alignment
Date: Sun, 17 Nov 2013 12:23:51 +0100
From: Toon Moene <toon@moene.org>
Im also quite convinced that we are hampered by the fact that
there is no IPA on alignment in GCC.
so I hacked together:

Gathering of get_pointer_alignment_1 results

Lattice propagation

Storing result to set_ptr_info_alignment


Propagation of alignment
Date: Sun, 17 Nov 2013 12:23:51 +0100
From: Toon Moene <toon@moene.org>
Im also quite convinced that we are hampered by the fact that
there is no IPA on alignment in GCC.
so I hacked together:

Gathering of get_pointer_alignment_1 results

Lattice propagation

Storing result to set_ptr_info_alignment


Results
| Polyhedron | pointer | known | % |
| Benchmark | params | alignment | |
|----------------+---------+-----------+-------|
| aermod | 256 | 99 | 38.67 |
| air | 32 | 22 | 68.75 |
| capacita | 15 | 3 | 20.00 |
| doduc | 84 | 6 | 7.14 |
| nf | 12 | 4 | 33.33 |
| protein | 81 | 1 | 1.23 |
| rnflow | 65 | 7 | 10.77 |
| test_fpu2 | 51 | 13 | 25.49 |
None in 9 other benchmarks.
More future work

Lots of cleanup

Return functions

Fortran devirtualization :-)

Any more ideas?


More future work

Lots of cleanup

Return functions

Fortran devirtualization :-)

Any more ideas?


More future work

Lots of cleanup

Return functions

Fortran devirtualization :-)

Any more ideas?


More future work

Lots of cleanup

Return functions

Fortran devirtualization :-)

Any more ideas?


Thank you.

Potrebbero piacerti anche