]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/cmd/compile/internal/inline/inlheur/dumpscores_test.go
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / src / cmd / compile / internal / inline / inlheur / dumpscores_test.go
index ddb9fecff9aed0b083248780d5bd330a1590cf25..438b70096f2a3dbd4fe8162407980b07ddb6b910 100644 (file)
@@ -17,16 +17,18 @@ func TestDumpCallSiteScoreDump(t *testing.T) {
        testenv.MustHaveGoBuild(t)
 
        scenarios := []struct {
-               name      string
-               promoted  int
-               demoted   int
-               unchanged int
+               name               string
+               promoted           int
+               indirectlyPromoted int
+               demoted            int
+               unchanged          int
        }{
                {
-                       name:      "dumpscores",
-                       promoted:  1,
-                       demoted:   1,
-                       unchanged: 5,
+                       name:               "dumpscores",
+                       promoted:           1,
+                       indirectlyPromoted: 1,
+                       demoted:            1,
+                       unchanged:          5,
                },
        }
 
@@ -41,13 +43,16 @@ func TestDumpCallSiteScoreDump(t *testing.T) {
                } else {
                        lines = strings.Split(string(content), "\n")
                }
-               prom, dem, unch := 0, 0, 0
+               prom, indprom, dem, unch := 0, 0, 0, 0
                for _, line := range lines {
                        switch {
                        case strings.TrimSpace(line) == "":
+                       case !strings.Contains(line, "|"):
                        case strings.HasPrefix(line, "#"):
                        case strings.Contains(line, "PROMOTED"):
                                prom++
+                       case strings.Contains(line, "INDPROM"):
+                               indprom++
                        case strings.Contains(line, "DEMOTED"):
                                dem++
                        default:
@@ -60,6 +65,11 @@ func TestDumpCallSiteScoreDump(t *testing.T) {
                                scen.name, prom, scen.promoted)
                        showout = true
                }
+               if indprom != scen.indirectlyPromoted {
+                       t.Errorf("testcase %q, got %d indirectly promoted want %d",
+                               scen.name, indprom, scen.indirectlyPromoted)
+                       showout = true
+               }
                if dem != scen.demoted {
                        t.Errorf("testcase %q, got %d demoted want %d demoted",
                                scen.name, dem, scen.demoted)
@@ -88,6 +98,7 @@ func gatherInlCallSitesScoresForFile(t *testing.T, testcase string, td string) (
        run := []string{testenv.GoToolPath(t), "build",
                "-gcflags=-d=dumpinlcallsitescores=1", "-o", outpath, gopath}
        out, err := testenv.Command(t, run[0], run[1:]...).CombinedOutput()
+       t.Logf("run: %+v\n", run)
        if err != nil {
                return "", err
        }