Description
The go/analysis Fact mechanism allows an analysis to associate information with the symbols defined by one package so that it may be retrieved during analysis of another package that imports these symbols. Facts must be pointers to gob-serializable data structures. In many analyses, facts naturally correspond to nodes in some domain-specific graph representation, so that two or more facts conceptually share a large common data structure such as a call graph. It would be a pity if the encoding of such facts caused the representation to explode by a linear factor.
The current specification of the analysis API permits a driver implementation to encode a collection of facts in a single gob operation, so that any shared portions are encoded exactly once and decoding preserves the original topology. The existing drivers in x/tools use the facts helper package and thus already function in this way; this has been verified experimentally.
I propose to change the specification to state that this behavior is required by all drivers. In the meantime, any existing third-party drivers that do not conform may run slower and use more memory for new analysis passes that assume this requirement, but should otherwise compute the correct answer.