cmd/gc: fix detection of initialization loop.

The compiler computes initialization order by finding
a spanning tree between a package's global variables.
But it does so by walking both variables and functions
and stops detecting cycles between variables when they
mix with a cycle of mutually recursive functions.

Fixes issue 4847.

R=golang-dev, daniel.morsing, rsc
CC=golang-dev
https://codereview.appspot.com/9663047