"strings"
)
+// IsIntrinsicCall reports whether the compiler back end will treat the call as an intrinsic operation.
+var IsIntrinsicCall = func(*ir.CallExpr) bool { return false }
+
// Inlining budget parameters, gathered in one place
const (
inlineMaxBudget = 80
}
}
- if isIntrinsicCall(n) {
+ if IsIntrinsicCall(n) {
// Treat like any other node.
break
}
if base.Flag.LowerM > 3 {
fmt.Printf("%v:call to func %+v\n", ir.Line(n), call.Left())
}
- if isIntrinsicCall(call) {
+ if IsIntrinsicCall(call) {
break
}
if fn := inlCallee(call.Left()); fn != nil && fn.Inl != nil {
var inlgen int
+// SSADumpInline gives the SSA back end a chance to dump the function
+// when producing output for debugging the compiler itself.
+var SSADumpInline = func(*ir.Func) {}
+
// If n is a call node (OCALLFUNC or OCALLMETH), and fn is an ONAME node for a
// function with an inlinable body, return an OINLCALL node that can replace n.
// The returned node's Ninit has the parameter assignments, the Nbody is the
fmt.Printf("%v: Before inlining: %+v\n", ir.Line(n), n)
}
- if ssaDump != "" && ssaDump == ir.FuncName(Curfn) {
- ssaDumpInlined = append(ssaDumpInlined, fn)
- }
+ SSADumpInline(fn)
ninit := n.Init()
logopt.LogJsonOption(base.Flag.JSON)
}
+ IsIntrinsicCall = isIntrinsicCall
+ SSADumpInline = ssaDumpInline
+
ssaDump = os.Getenv("GOSSAFUNC")
ssaDir = os.Getenv("GOSSADIR")
if ssaDump != "" {
// pointer variables in the function and emits a runtime data
// structure read by the garbage collector.
// Returns a map from GC safe points to their corresponding stack map index.
-func liveness(e *ssafn, f *ssa.Func, pp *Progs) LivenessMap {
+func liveness(curfn *ir.Func, f *ssa.Func, stkptrsize int64, pp *Progs) LivenessMap {
// Construct the global liveness state.
- vars, idx := getvariables(e.curfn)
- lv := newliveness(e.curfn, f, vars, idx, e.stkptrsize)
+ vars, idx := getvariables(curfn)
+ lv := newliveness(curfn, f, vars, idx, stkptrsize)
// Run the dataflow framework.
lv.prologue()
}
// Emit the live pointer map data structures
- ls := e.curfn.LSym
+ ls := curfn.LSym
fninfo := ls.Func()
fninfo.GCArgs, fninfo.GCLocals = lv.emit()
// ssaDumpInlined holds all inlined functions when ssaDump contains a function name.
var ssaDumpInlined []*ir.Func
+func ssaDumpInline(fn *ir.Func) {
+ if ssaDump != "" && ssaDump == ir.FuncName(fn) {
+ ssaDumpInlined = append(ssaDumpInlined, fn)
+ }
+}
+
func initssaconfig() {
types_ := ssa.NewTypes()
// Expression statements
case ir.OCALLFUNC:
n := n.(*ir.CallExpr)
- if isIntrinsicCall(n) {
+ if IsIntrinsicCall(n) {
s.intrinsicCall(n)
return
}
case ir.OAS2FUNC:
// We come here only when it is an intrinsic call returning two values.
call := n.Rlist().First().(*ir.CallExpr)
- if !isIntrinsicCall(call) {
+ if !IsIntrinsicCall(call) {
s.Fatalf("non-intrinsic AS2FUNC not expanded %v", call)
}
v := s.intrinsicCall(call)
case ir.OCALLFUNC:
n := n.(*ir.CallExpr)
- if isIntrinsicCall(n) {
+ if IsIntrinsicCall(n) {
return s.intrinsicCall(n)
}
fallthrough
e := f.Frontend().(*ssafn)
- s.livenessMap = liveness(e, f, pp)
+ s.livenessMap = liveness(e.curfn, f, e.stkptrsize, pp)
emitStackObjects(e, pp)
openDeferInfo := e.curfn.LSym.Func().OpenCodedDeferInfo
walkexprlistsafe(n.List().Slice(), init)
r = walkexpr(r, init)
- if isIntrinsicCall(r.(*ir.CallExpr)) {
+ if IsIntrinsicCall(r.(*ir.CallExpr)) {
n.PtrRlist().Set1(r)
return n
}