]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/ir: add "never returns" func flag
authorThan McIntosh <thanm@google.com>
Tue, 1 Aug 2023 16:00:57 +0000 (12:00 -0400)
committerThan McIntosh <thanm@google.com>
Wed, 6 Sep 2023 18:29:16 +0000 (18:29 +0000)
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>

src/cmd/compile/internal/ir/func.go

index e3db3ed9ea27ae0772fc63eee84035bcb5d655f5..0e44ea7c5278c73cbd39de6239f87a180f713784 100644 (file)
@@ -232,7 +232,7 @@ const (
        funcHasDefer                 // contains a defer statement
        funcNilCheckDisabled         // disable nil checks when compiling this function
        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
        funcOpenCodedDeferDisallowed // can't do open-coded defers
        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) NilCheckDisabled() bool         { return f.flags&funcNilCheckDisabled != 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) OpenCodedDeferDisallowed() bool { return f.flags&funcOpenCodedDeferDisallowed != 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) SetNilCheckDisabled(b bool)         { f.flags.set(funcNilCheckDisabled, 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) SetOpenCodedDeferDisallowed(b bool) { f.flags.set(funcOpenCodedDeferDisallowed, b) }
 func (f *Func) SetClosureResultsLost(b bool)       { f.flags.set(funcClosureResultsLost, b) }