Regres: Re-populate treeFile.allSpans on parse.

This caused `TestTreeEncodeDecode` to fail, and would make the reparsing of a coverage file incorrect.

Bug: b/152192800
Change-Id: Ic9f4c49c58350509f74755fec20f22b6c1213877
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/43569
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
diff --git a/tests/regres/cov/serialization.go b/tests/regres/cov/serialization.go
index 76bd2e1..b7d29c9 100644
--- a/tests/regres/cov/serialization.go
+++ b/tests/regres/cov/serialization.go
@@ -312,9 +312,35 @@
 	if p.err != nil {
 		return nil, "", p.err
 	}
+
+	p.populateAllSpans(&p.tree)
+
 	return &p.tree, p.revision, nil
 }
 
+// populateAllSpans() adds all the coverage spans to each treeFile.allSpans.
+func (p *parser) populateAllSpans(tree *Tree) {
+	spansByID := map[SpanID]Span{}
+	for span, id := range tree.spans {
+		spansByID[id] = span
+	}
+	for _, tf := range tree.files {
+		tf.tcm.traverse(func(tc *TestCoverage) {
+			for spanID := range tc.Spans {
+				span := spansByID[spanID]
+				tf.allSpans.Add(span)
+			}
+			if groupID := tc.Group; groupID != nil {
+				group := tf.spangroups[*groupID]
+				for spanID := range group.Spans {
+					span := spansByID[spanID]
+					tf.allSpans.Add(span)
+				}
+			}
+		})
+	}
+}
+
 func (p *parser) parseStrings() {
 	p.array(func(idx int) {
 		id := StringID(idx)