compiler: speed up variable initializer sorting
commitb23c1ce004e1edf618391a8ef7850ffb753345b4
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 7 Jun 2018 16:56:09 +0000 (7 16:56 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 7 Jun 2018 16:56:09 +0000 (7 16:56 +0000)
tree81494302b4f5708ad6c96bad6ecfd9c109574c38
parent5aed9a067fd3361ab56052151e9ec33893ade63f
compiler: speed up variable initializer sorting

    The compiler used to do variable initializer sorting by looping
    through all the initialized variables and, for each one, looping
    through all the initialized variables and checking for a dependency.
    For very large packages with thousands of initialized global
    variables, this quadratic loop could take quite a long time.

    Change the approach to first loop through all the initialized
    variables and fetch all the references to other variables from the
    initialization code.  Then, loop through them again and this time add
    a dependency for each referenced, initialized, variable, while
    checking for initialization loops.  We still have a nested loop, but
    this time the inner loop should normally be short--just the list of
    referenced variables, not the list of all variables.

    Reviewed-on: https://go-review.googlesource.com/116816

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@261284 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/go/gofrontend/MERGE
gcc/go/gofrontend/gogo.cc