mirror of https://github.com/golang/go.git
cmd/compile: gracefully fail when devirtualization fails
We should still be able to devirtualize here, but I need to understand the AST better. While I'm doing that, at least switch to a graceful failure case (i.e., skip the optimization and print a warning message) to fix the x/text builders. Updates #42279. Change-Id: Ie2b0b701fccf590d0cabfead703fc2fa999072cf Reviewed-on: https://go-review.googlesource.com/c/go/+/266359 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
5cc43c51c9
commit
aa4f48b751
|
|
@ -1442,16 +1442,20 @@ func devirtualizeCall(call *Node) {
|
|||
return
|
||||
}
|
||||
|
||||
if Debug.m != 0 {
|
||||
Warnl(call.Pos, "devirtualizing %v to %v", call.Left, typ)
|
||||
}
|
||||
|
||||
x := nodl(call.Left.Pos, ODOTTYPE, call.Left.Left, nil)
|
||||
x.Type = typ
|
||||
x = nodlSym(call.Left.Pos, OXDOT, x, call.Left.Sym)
|
||||
x = typecheck(x, ctxExpr|ctxCallee)
|
||||
if x.Op != ODOTMETH {
|
||||
Fatalf("devirtualization failed: %v", x)
|
||||
// TODO(mdempsky): Figure out how to avoid this and
|
||||
// turn back into a Fatalf.
|
||||
if Debug.m != 0 {
|
||||
Warnl(call.Pos, "failed to devirtualize %v", x)
|
||||
}
|
||||
return
|
||||
}
|
||||
if Debug.m != 0 {
|
||||
Warnl(call.Pos, "devirtualizing %v to %v", call.Left, typ)
|
||||
}
|
||||
call.Op = OCALLMETH
|
||||
call.Left = x
|
||||
|
|
|
|||
Loading…
Reference in New Issue