[dev.regabi] cmd/compile: some more manual shuffling

More minor reshuffling of passes.

Passes toolstash -cmp.

Change-Id: I22633b3741f668fc5ee8579d7d610035ed57df1f
Reviewed-on: https://go-review.googlesource.com/c/go/+/280975
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
This commit is contained in:
Matthew Dempsky 2020-12-31 23:39:15 -08:00
parent 0f1d2129c4
commit 3a4474cdfd
7 changed files with 29 additions and 33 deletions

View file

@ -200,23 +200,15 @@ func Main(archInit func(*ssagen.ArchInfo)) {
base.AutogeneratedPos = makePos(src.NewFileBase("<autogenerated>", "<autogenerated>"), 1, 0)
typecheck.Init()
typecheck.InitUniverse()
// Parse and typecheck input.
noder.LoadPackage(flag.Args())
// Parse input.
base.Timer.Start("fe", "parse")
lines := noder.ParseFiles(flag.Args())
ssagen.CgoSymABIs()
base.Timer.Stop()
base.Timer.AddEvent(int64(lines), "lines")
dwarfgen.RecordPackageName()
ssagen.CgoSymABIs()
// Typecheck.
noder.Package()
// With all user code typechecked, it's now safe to verify unused dot imports.
noder.CheckDotImports()
base.ExitIfErrors()
// Phase 6: Compute Addrtaken for names.
// Compute Addrtaken for names.
// We need to wait until typechecking is done so that when we see &x[i]
// we know that x has its address taken if x is an array, but not if x is a slice.
// We compute Addrtaken in bulk here.
@ -227,7 +219,7 @@ func Main(archInit func(*ssagen.ArchInfo)) {
}
typecheck.IncrementalAddrtaken = true
// Phase 7: Eliminate some obviously dead code.
// Eliminate some obviously dead code.
// Must happen after typechecking.
for _, n := range typecheck.Target.Decls {
if n.Op() == ir.ODCLFUNC {
@ -235,7 +227,7 @@ func Main(archInit func(*ssagen.ArchInfo)) {
}
}
// Phase 8: Decide how to capture closed variables.
// Decide how to capture closed variables.
// This needs to run before escape analysis,
// because variables captured by value do not escape.
base.Timer.Start("fe", "capturevars")
@ -256,6 +248,7 @@ func Main(archInit func(*ssagen.ArchInfo)) {
// otherwise lazily when used or re-exported.
typecheck.AllImportedBodies()
}
// Build init task.
if initTask := pkginit.Task(); initTask != nil {
typecheck.Export(initTask)
@ -311,6 +304,7 @@ func Main(archInit func(*ssagen.ArchInfo)) {
// Prepare for SSA compilation.
// This must be before peekitabs, because peekitabs
// can trigger function compilation.
typecheck.InitRuntime()
ssagen.InitConfig()
// Just before compilation, compile itabs found on