Go to file
Alan Donovan 5b55a71008 go.tools/pointer: strength reduction during constraint generation.
Motivation: simple constraints---copy and addr---are more
amenable to pre-solver optimizations (forthcoming) than
complex constraints: load, store, and all others.

In code such as the following:

         t0 = new struct { x, y int }
         t1 = &t0.y
         t2 = *t1

there's no need for the full generality of a (complex)
load constraint for t2=*t1 since t1 can only point to t0.y.
All we need is a (simple) copy constraint t2 = (t0.y)
where (t0.y) is the object node label for that field.

For all "addressable" SSA instructions, we tabulate
whether their points-to set is necessarily a singleton.  For
some (e.g. Alloc, MakeSlice, etc) this is always true by
design.  For others (e.g. FieldAddr) it depends on their
operands.

We exploit this information when generating constraints:
all load-form and store-form constraints are reduced to copy
constraints if the pointer's PTS is a singleton.
Similarly all FieldAddr (y=&x.f) and IndexAddr (y=&x[0])
constraints are reduced to offset addition, for singleton
operands.

Here's the constraint mix when running on the oracle itself.
The total number of constraints is unchanged but the fraction
that are complex has gone down to 21% from 53%.

                before    after
--simple--
 addr		20682     46949
 copy        	61454     91211
--complex--
 offsetAddr  	41621     15325
 load        	18769     12925
 store       	30758     6908
 invoke      	758       760
 typeAssert  	1688      1689
total           175832    175869

Also:
- Add Pointer.Context() for local variables,
  since we now plumb cgnodes throughout. Nice.
- Refactor all load-form (load, receive, lookup) and
  store-form (Store, send, MapUpdate) constraints to use
  genLoad and genStore.
- Log counts of constraints by type.
- valNodes split into localval and globalval maps;
  localval is purged after each function.
- analogous maps localobj[v] and globalobj[v] hold sole label
  for pts(v), if singleton.
- fnObj map subsumed by globalobj.
- make{Function/Global/Constant} inlined into objectValue.
  Much cleaner.

R=crawshaw
CC=golang-dev
https://golang.org/cl/13979043
2013-09-27 11:33:01 -04:00
blog go.tools/blog: use atom and present packages from go.tools 2013-09-19 10:58:36 +10:00
call go.tools/pointer: use new callgraph API. 2013-09-25 17:17:42 -04:00
cmd go.tools/cmd/html2article: move command from go.blog repository 2013-09-27 10:40:53 +10:00
dashboard go.tools/dashboard/builder: only download gcc once for gccgo buildTool. 2013-09-24 16:08:25 -07:00
go go.tools/go/types: fix incorrect argument to fmt.Printf 2013-09-26 20:34:35 -07:00
godoc go.tools/present: add -edit and -numbers flags to .code/.play 2013-09-27 09:46:08 +10:00
importer go.tools/go/types: separate package descriptor from package object 2013-09-13 09:52:57 -07:00
oracle go.tool.pointer: fix regression in pointer.cgraph.Root(). 2013-09-26 09:31:39 -04:00
playground go.tools/playground/socket: move package from go.talks 2013-09-19 10:59:00 +10:00
pointer go.tools/pointer: strength reduction during constraint generation. 2013-09-27 11:33:01 -04:00
present go.tools/present: add -edit and -numbers flags to .code/.play 2013-09-27 09:46:08 +10:00
ssa go.tools/ssa: SSA fixes for *types.Builtin becoming an object (CL 13813043) 2013-09-23 18:18:35 -04:00
.hgignore go.empty: prototype for new subrepository 2012-01-25 14:45:13 -05:00
AUTHORS go.empty: prototype for new subrepository 2012-01-25 14:45:13 -05:00
CONTRIBUTORS go.empty: prototype for new subrepository 2012-01-25 14:45:13 -05:00
LICENSE LICENSE: add 2012-03-17 15:20:58 +11:00
PATENTS go.empty: add PATENTS file to the subrepo. 2012-04-16 11:24:04 +10:00
README go.tools: provide the right README 2013-05-17 12:55:10 -07:00
codereview.cfg go.empty: prototype for new subrepository 2012-01-25 14:45:13 -05:00

README

This subrepository holds the source for various packages and tools that support
the Go programming language.

Although at least some of the tools themselves will be included in binary Go distributions,
the packages from which they are built are of little interest to most Go programmers.

To submit changes to this repository, see http://golang.org/doc/contribute.html.