mirror of
				https://github.com/golang/go.git
				synced 2025-11-03 18:20:59 +00:00 
			
		
		
		
	[dev.typeparams] cmd/compile: flatten OINLCALL in walk
Inlining replaces inlined calls with OINLCALL nodes, and then somewhat clumsily tries to rewrite these in place without messing up order-of-evaluation rules. But handling these rules cleanly is much easier to do during order, and escape analysis is the only major pass between inlining and order. It's simpler to teach escape analysis how to analyze OINLCALL nodes than to try to hide them from escape analysis. Does not pass toolstash -cmp, but seems to just be line number changes. Change-Id: I1986cea39793e3e1ed5e887ba29d46364c6c532e Reviewed-on: https://go-review.googlesource.com/c/go/+/332649 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Trust: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
		
							parent
							
								
									ad2ba3ff51
								
							
						
					
					
						commit
						c45d0eaadb
					
				
					 10 changed files with 102 additions and 100 deletions
				
			
		| 
						 | 
				
			
			@ -345,7 +345,7 @@ func (n *StructKeyExpr) Sym() *types.Sym { return n.Field.Sym }
 | 
			
		|||
type InlinedCallExpr struct {
 | 
			
		||||
	miniExpr
 | 
			
		||||
	Body       Nodes
 | 
			
		||||
	ReturnVars Nodes
 | 
			
		||||
	ReturnVars Nodes // must be side-effect free
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewInlinedCallExpr(pos src.XPos, body, retvars []Node) *InlinedCallExpr {
 | 
			
		||||
| 
						 | 
				
			
			@ -357,6 +357,13 @@ func NewInlinedCallExpr(pos src.XPos, body, retvars []Node) *InlinedCallExpr {
 | 
			
		|||
	return n
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (n *InlinedCallExpr) SingleResult() Node {
 | 
			
		||||
	if have := len(n.ReturnVars); have != 1 {
 | 
			
		||||
		base.FatalfAt(n.Pos(), "inlined call has %v results, expected 1", have)
 | 
			
		||||
	}
 | 
			
		||||
	return n.ReturnVars[0]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// A LogicalExpr is a expression X Op Y where Op is && or ||.
 | 
			
		||||
// It is separate from BinaryExpr to make room for statements
 | 
			
		||||
// that must be executed before Y but after X.
 | 
			
		||||
| 
						 | 
				
			
			@ -800,6 +807,11 @@ func StaticValue(n Node) Node {
 | 
			
		|||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if n.Op() == OINLCALL {
 | 
			
		||||
			n = n.(*InlinedCallExpr).SingleResult()
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		n1 := staticValue1(n)
 | 
			
		||||
		if n1 == nil {
 | 
			
		||||
			return n
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue