From: Matthew Dempsky Date: Mon, 14 Dec 2015 20:37:26 +0000 (-0800) Subject: cmd/compile: change dead code into assert X-Git-Tag: go1.6beta1~77 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=22a204dd0fd9003ae51318f5f67f43937b59ee87;p=gostls13.git cmd/compile: change dead code into assert After fixing #13587, I noticed that the "OAS2FUNC in disguise" block looked like it probably needed write barriers too. However, testing revealed the multi-value "return f()" case was already being handled correctly. It turns out this block is dead code due to "return f()" already being transformed into "t1, t2, ..., tN := f(); return t1, t2, ..., tN" by orderstmt when f is a multi-valued function. Updates #13587. Change-Id: Icde46dccc55beda2ea5fd5fcafc9aae26cec1552 Reviewed-on: https://go-review.googlesource.com/17759 Run-TryBot: Matthew Dempsky TryBot-Result: Gobot Gobot Reviewed-by: Keith Randall --- diff --git a/src/cmd/compile/internal/gc/walk.go b/src/cmd/compile/internal/gc/walk.go index d4dc81a1e3..25cd828b9b 100644 --- a/src/cmd/compile/internal/gc/walk.go +++ b/src/cmd/compile/internal/gc/walk.go @@ -299,6 +299,12 @@ func walkstmt(np **Node) { } } + if got, want := count(n.List), count(rl); got != want { + // order should have rewritten multi-value function calls + // with explicit OAS2FUNC nodes. + Fatalf("expected %v return arguments, have %v", want, got) + } + if samelist(rl, n.List) { // special return in disguise n.List = nil @@ -306,17 +312,6 @@ func walkstmt(np **Node) { break } - if count(n.List) == 1 && count(rl) > 1 { - // OAS2FUNC in disguise - f := n.List.N - - if f.Op != OCALLFUNC && f.Op != OCALLMETH && f.Op != OCALLINTER { - Fatalf("expected return of call, have %v", f) - } - n.List = concat(list1(f), ascompatet(n.Op, rl, &f.Type, 0, &n.Ninit)) - break - } - // move function calls out, to make reorder3's job easier. walkexprlistsafe(n.List, &n.Ninit)