mirror of
https://github.com/golang/go
synced 2024-10-05 22:21:23 -06:00
[dev.ssa] cmd/compile: don't Compile if Unimplemented
If we've already hit an Unimplemented, there may be important SSA invariants that do not hold and which could cause ssa.Compile to hang or spin. While we're here, make detected dependency cycles stop execution. Change-Id: Ic7d4eea659e1fe3f2c9b3e8a4eee5567494f46ad Reviewed-on: https://go-review.googlesource.com/12310 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
cd7e059496
commit
766bcc92a5
@ -108,17 +108,18 @@ func buildssa(fn *Node) (ssafn *ssa.Func, usessa bool) {
|
|||||||
// Link up variable uses to variable definitions
|
// Link up variable uses to variable definitions
|
||||||
s.linkForwardReferences()
|
s.linkForwardReferences()
|
||||||
|
|
||||||
// Main call to ssa package to compile function
|
|
||||||
ssa.Compile(s.f)
|
|
||||||
|
|
||||||
// Calculate stats about what percentage of functions SSA handles.
|
// Calculate stats about what percentage of functions SSA handles.
|
||||||
if false {
|
if false {
|
||||||
fmt.Printf("SSA implemented: %t\n", !e.unimplemented)
|
defer func() { fmt.Printf("SSA implemented: %t\n", !e.unimplemented) }()
|
||||||
}
|
}
|
||||||
|
|
||||||
if e.unimplemented {
|
if e.unimplemented {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Main call to ssa package to compile function.
|
||||||
|
ssa.Compile(s.f)
|
||||||
|
|
||||||
return s.f, usessa // TODO: return s.f, true once runtime support is in (gc maps, write barriers, etc.)
|
return s.f, usessa // TODO: return s.f, true once runtime support is in (gc maps, write barriers, etc.)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
func printFunc(f *Func) {
|
func printFunc(f *Func) {
|
||||||
@ -68,16 +69,22 @@ func fprintFunc(w io.Writer, f *Func) {
|
|||||||
n++
|
n++
|
||||||
}
|
}
|
||||||
if m == n {
|
if m == n {
|
||||||
fmt.Fprintln(w, "dependency cycle!")
|
fmt.Fprintln(os.Stderr, "dependency cycle in block", b)
|
||||||
for _, v := range b.Values {
|
for _, v := range b.Values {
|
||||||
if printed[v.ID] {
|
if printed[v.ID] {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fmt.Fprint(w, " ")
|
fmt.Fprintf(os.Stderr, " %v\n", v.LongString())
|
||||||
fmt.Fprintln(w, v.LongString())
|
|
||||||
printed[v.ID] = true
|
printed[v.ID] = true
|
||||||
n++
|
n++
|
||||||
}
|
}
|
||||||
|
// Things are going to go very badly from here;
|
||||||
|
// one of the optimization passes is likely to hang.
|
||||||
|
// Frustratingly, panics here get swallowed by fmt,
|
||||||
|
// and just we end up here again if we call Fatalf.
|
||||||
|
// Use our last resort.
|
||||||
|
os.Exit(1)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user