Add TemplateInstance::tnext to construct instantiation dependency graph

This is the final improvement for the template instantiation model.

To detect speculative instantiations in codegen phase, `tnext` is neccesary for the `test6()` case `runnable/link13350.d`. That's a big difference from the PR #2550.