]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: fix a premature-deallocation of state in loopreschedchecks
authorJunyang Shao <shaojunyang@google.com>
Sat, 30 Nov 2024 04:15:07 +0000 (04:15 +0000)
committerJunyang Shao <shaojunyang@google.com>
Tue, 3 Dec 2024 16:22:55 +0000 (16:22 +0000)
lastMems is free-ed before it's actually used. This results in the pass
breaking: multiple mem phis will present in the instrumented ssa, and
essentially break tighten
pass(https://cs.opensource.google/go/go/+/master:src/cmd/compile/internal/ssa/tighten.go;l=240).

This CL fix that.

Change-Id: I30cf0c3300ed59d1a15d978757a3840fbe04484d
Reviewed-on: https://go-review.googlesource.com/c/go/+/632516
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/compile/internal/ssa/loopreschedchecks.go

index 0ac473d229474dbc7a6040edfb645df60f82175b..125c468217dbf45bba4f85633205f0fd094919dc 100644 (file)
@@ -71,6 +71,7 @@ func insertLoopReschedChecks(f *Func) {
        }
 
        lastMems := findLastMems(f)
+       defer f.Cache.freeValueSlice(lastMems)
 
        idom := f.Idom()
        po := f.postorder()
@@ -406,7 +407,6 @@ func findLastMems(f *Func) []*Value {
 
        var stores []*Value
        lastMems := f.Cache.allocValueSlice(f.NumBlocks())
-       defer f.Cache.freeValueSlice(lastMems)
        storeUse := f.newSparseSet(f.NumValues())
        defer f.retSparseSet(storeUse)
        for _, b := range f.Blocks {