1
0
mirror of https://github.com/golang/go synced 2024-11-19 00:44:40 -07:00

cmd/compile/internal/ir: add "never returns" func flag

Add a flag to ir.Func's flags field to record whether a given function
is deemed to never return (e.g. always calls exit or panic or
equivalent on all control paths). So as to not increase the amount of
flag storage, this new flag replaces the existing "ExportInline" flag,
which is currently unused.

Change-Id: Idd336e47381048cfc995eda05faf8b62f06ba206
Reviewed-on: https://go-review.googlesource.com/c/go/+/518256
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Than McIntosh 2023-08-01 12:00:57 -04:00
parent a0c3a1b676
commit 3d62c76736

View File

@ -232,7 +232,7 @@ const (
funcHasDefer // contains a defer statement funcHasDefer // contains a defer statement
funcNilCheckDisabled // disable nil checks when compiling this function funcNilCheckDisabled // disable nil checks when compiling this function
funcInlinabilityChecked // inliner has already determined whether the function is inlinable funcInlinabilityChecked // inliner has already determined whether the function is inlinable
funcExportInline // include inline body in export data funcNeverReturns // function never returns (in most cases calls panic(), os.Exit(), or equivalent)
funcInstrumentBody // add race/msan/asan instrumentation during SSA construction funcInstrumentBody // add race/msan/asan instrumentation during SSA construction
funcOpenCodedDeferDisallowed // can't do open-coded defers funcOpenCodedDeferDisallowed // can't do open-coded defers
funcClosureResultsLost // closure is called indirectly and we lost track of its results; used by escape analysis funcClosureResultsLost // closure is called indirectly and we lost track of its results; used by escape analysis
@ -254,7 +254,7 @@ func (f *Func) IsDeadcodeClosure() bool { return f.flags&funcIsDeadcodeCl
func (f *Func) HasDefer() bool { return f.flags&funcHasDefer != 0 } func (f *Func) HasDefer() bool { return f.flags&funcHasDefer != 0 }
func (f *Func) NilCheckDisabled() bool { return f.flags&funcNilCheckDisabled != 0 } func (f *Func) NilCheckDisabled() bool { return f.flags&funcNilCheckDisabled != 0 }
func (f *Func) InlinabilityChecked() bool { return f.flags&funcInlinabilityChecked != 0 } func (f *Func) InlinabilityChecked() bool { return f.flags&funcInlinabilityChecked != 0 }
func (f *Func) ExportInline() bool { return f.flags&funcExportInline != 0 } func (f *Func) NeverReturns() bool { return f.flags&funcNeverReturns != 0 }
func (f *Func) InstrumentBody() bool { return f.flags&funcInstrumentBody != 0 } func (f *Func) InstrumentBody() bool { return f.flags&funcInstrumentBody != 0 }
func (f *Func) OpenCodedDeferDisallowed() bool { return f.flags&funcOpenCodedDeferDisallowed != 0 } func (f *Func) OpenCodedDeferDisallowed() bool { return f.flags&funcOpenCodedDeferDisallowed != 0 }
func (f *Func) ClosureResultsLost() bool { return f.flags&funcClosureResultsLost != 0 } func (f *Func) ClosureResultsLost() bool { return f.flags&funcClosureResultsLost != 0 }
@ -270,7 +270,7 @@ func (f *Func) SetIsDeadcodeClosure(b bool) { f.flags.set(funcIsDeadcodeC
func (f *Func) SetHasDefer(b bool) { f.flags.set(funcHasDefer, b) } func (f *Func) SetHasDefer(b bool) { f.flags.set(funcHasDefer, b) }
func (f *Func) SetNilCheckDisabled(b bool) { f.flags.set(funcNilCheckDisabled, b) } func (f *Func) SetNilCheckDisabled(b bool) { f.flags.set(funcNilCheckDisabled, b) }
func (f *Func) SetInlinabilityChecked(b bool) { f.flags.set(funcInlinabilityChecked, b) } func (f *Func) SetInlinabilityChecked(b bool) { f.flags.set(funcInlinabilityChecked, b) }
func (f *Func) SetExportInline(b bool) { f.flags.set(funcExportInline, b) } func (f *Func) SetNeverReturns(b bool) { f.flags.set(funcNeverReturns, b) }
func (f *Func) SetInstrumentBody(b bool) { f.flags.set(funcInstrumentBody, b) } func (f *Func) SetInstrumentBody(b bool) { f.flags.set(funcInstrumentBody, b) }
func (f *Func) SetOpenCodedDeferDisallowed(b bool) { f.flags.set(funcOpenCodedDeferDisallowed, b) } func (f *Func) SetOpenCodedDeferDisallowed(b bool) { f.flags.set(funcOpenCodedDeferDisallowed, b) }
func (f *Func) SetClosureResultsLost(b bool) { f.flags.set(funcClosureResultsLost, b) } func (f *Func) SetClosureResultsLost(b bool) { f.flags.set(funcClosureResultsLost, b) }