Skip to content

Commit 15f01d6

Browse files
committed
cmd/compile: delay expansion of OpArg until expand_calls
As it says, delay expanpsion of OpArg to the expand_calls phase, to enable (eventually) interprocedural SSA optimizations, and (sooner) change to a register ABI. Includes a round of cleanup to function names and comments, largely to match the expanded scope of the functions. This CL removes the per-function dependence on GOSSAHASH, but the go116lateCallExpansion kill switch remains (and was tested locally to ensure it worked). Two functions in expand_calls.go that performed overlapping things were combined into a single function that is called twice. Fixes #42236. For #40724. Change-Id: Icbb78947eaa39f17f2c1210d5c2caef20abd6571 Reviewed-on: https://go-review.googlesource.com/c/go/+/262117 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
1 parent 7fe2a84 commit 15f01d6

File tree

8 files changed

+329
-124
lines changed

8 files changed

+329
-124
lines changed

src/cmd/compile/fmtmap_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ var knownFormats = map[string]string{
136136
"cmd/compile/internal/types.EType %s": "",
137137
"cmd/compile/internal/types.EType %v": "",
138138
"cmd/internal/obj.ABI %v": "",
139-
"cmd/internal/src.XPos %v": "",
140139
"error %v": "",
141140
"float64 %.2f": "",
142141
"float64 %.3f": "",

src/cmd/compile/internal/gc/ssa.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,11 +409,17 @@ func buildssa(fn *Node, worker int) *ssa.Func {
409409

410410
// Generate addresses of local declarations
411411
s.decladdrs = map[*Node]*ssa.Value{}
412+
var args []ssa.Param
413+
var results []ssa.Param
412414
for _, n := range fn.Func.Dcl {
413415
switch n.Class() {
414-
case PPARAM, PPARAMOUT:
416+
case PPARAM:
417+
s.decladdrs[n] = s.entryNewValue2A(ssa.OpLocalAddr, types.NewPtr(n.Type), n, s.sp, s.startmem)
418+
args = append(args, ssa.Param{Type: n.Type, Offset: int32(n.Xoffset)})
419+
case PPARAMOUT:
415420
s.decladdrs[n] = s.entryNewValue2A(ssa.OpLocalAddr, types.NewPtr(n.Type), n, s.sp, s.startmem)
416-
if n.Class() == PPARAMOUT && s.canSSA(n) {
421+
results = append(results, ssa.Param{Type: n.Type, Offset: int32(n.Xoffset)})
422+
if s.canSSA(n) {
417423
// Save ssa-able PPARAMOUT variables so we can
418424
// store them back to the stack at the end of
419425
// the function.
@@ -4909,7 +4915,7 @@ func (s *state) canSSA(n *Node) bool {
49094915
if n.Class() == PPARAM && n.Sym != nil && n.Sym.Name == ".this" {
49104916
// wrappers generated by genwrapper need to update
49114917
// the .this pointer in place.
4912-
// TODO: treat as a PPARMOUT?
4918+
// TODO: treat as a PPARAMOUT?
49134919
return false
49144920
}
49154921
return canSSAType(n.Type)

src/cmd/compile/internal/ssa/compile.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ var passes = [...]pass{
429429
{name: "early copyelim", fn: copyelim},
430430
{name: "early deadcode", fn: deadcode}, // remove generated dead code to avoid doing pointless work during opt
431431
{name: "short circuit", fn: shortcircuit},
432-
{name: "decompose args", fn: decomposeArgs, required: true},
432+
{name: "decompose args", fn: decomposeArgs, required: !go116lateCallExpansion, disabled: go116lateCallExpansion}, // handled by late call lowering
433433
{name: "decompose user", fn: decomposeUser, required: true},
434434
{name: "pre-opt deadcode", fn: deadcode},
435435
{name: "opt", fn: opt, required: true}, // NB: some generic rules know the name of the opt pass. TODO: split required rules and optimizing rules

src/cmd/compile/internal/ssa/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ const (
199199
const go116lateCallExpansion = true
200200

201201
// LateCallExpansionEnabledWithin returns true if late call expansion should be tested
202-
// within compilation of a function/method triggered by GOSSAHASH (defaults to "yes").
202+
// within compilation of a function/method.
203203
func LateCallExpansionEnabledWithin(f *Func) bool {
204-
return go116lateCallExpansion && f.DebugTest // Currently set up for GOSSAHASH bug searches
204+
return go116lateCallExpansion
205205
}
206206

207207
// NewConfig returns a new configuration object for the given architecture.

0 commit comments

Comments
 (0)