File tree 2 files changed +16
-2
lines changed
src/cmd/compile/internal/ssa
2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ type Cache struct {
32
32
live []bool
33
33
q []* Value
34
34
}
35
+ // Reusable regalloc state.
36
+ regallocValues []valState
35
37
36
38
ValueToProgAfter []* obj.Prog
37
39
debugState debugState
@@ -56,6 +58,12 @@ func (c *Cache) Reset() {
56
58
xl [i ] = nil
57
59
}
58
60
61
+ // regalloc sets the length of c.regallocValues to whatever it may use,
62
+ // so clear according to length.
63
+ for i := range c .regallocValues {
64
+ c .regallocValues [i ] = valState {}
65
+ }
66
+
59
67
// liveOrderStmts gets used multiple times during compilation of a function.
60
68
// We don't know where the high water mark was, so reslice to cap and search.
61
69
c .deadcode .liveOrderStmts = c .deadcode .liveOrderStmts [:cap (c .deadcode .liveOrderStmts )]
Original file line number Diff line number Diff line change @@ -651,8 +651,14 @@ func (s *regAllocState) init(f *Func) {
651
651
}
652
652
653
653
s .regs = make ([]regState , s .numRegs )
654
- s .values = make ([]valState , f .NumValues ())
655
- s .orig = make ([]* Value , f .NumValues ())
654
+ nv := f .NumValues ()
655
+ if cap (s .f .Cache .regallocValues ) >= nv {
656
+ s .f .Cache .regallocValues = s .f .Cache .regallocValues [:nv ]
657
+ } else {
658
+ s .f .Cache .regallocValues = make ([]valState , nv )
659
+ }
660
+ s .values = s .f .Cache .regallocValues
661
+ s .orig = make ([]* Value , nv )
656
662
s .copies = make (map [* Value ]bool )
657
663
for _ , b := range s .visitOrder {
658
664
for _ , v := range b .Values {
You can’t perform that action at this time.
0 commit comments