]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: gracefully fail when devirtualization fails
authorMatthew Dempsky <mdempsky@google.com>
Thu, 29 Oct 2020 19:47:15 +0000 (12:47 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Thu, 29 Oct 2020 20:19:24 +0000 (20:19 +0000)
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>

src/cmd/compile/internal/gc/inl.go

index c35691bfd2143ab15cd6ed02b5de3bc9884ce55e..6c6986778982ceeab0daece944fcf9b9dad2a105 100644 (file)
@@ -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