mirror of
				https://github.com/golang/go.git
				synced 2025-10-31 16:50:58 +00:00 
			
		
		
		
	cmd/compile: use getcallersp for gorecover "fp" arg
Currently, the compiler synthesize a special ".fp" node, which points to the FP of the current frame, be to used to call gorecover. Later that node turns to an Arg in SSA that is not really an arg, causing problems for the new ABI work which changes the handling of Args, so we have to special-case that node. This CL changes the compiler to get the FP by using getcallersp, which is an intrinsic in SSA and works on all platforms. As we need the FP, not the caller SP, one drawback is that we have to add FixedFrameSize for LR machines. But it does allow us to remove that special node. Change-Id: Ie721d51efca8116c9d23cc4f79738fffcf847df8 Reviewed-on: https://go-review.googlesource.com/c/go/+/297930 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
		
							parent
							
								
									a22bd3dc73
								
							
						
					
					
						commit
						fb03be9d55
					
				
					 7 changed files with 11 additions and 18 deletions
				
			
		|  | @ -158,7 +158,14 @@ func walkExpr1(n ir.Node, init *ir.Nodes) ir.Node { | |||
| 
 | ||||
| 	case ir.ORECOVER: | ||||
| 		n := n.(*ir.CallExpr) | ||||
| 		return mkcall("gorecover", n.Type(), init, typecheck.NodAddr(ir.RegFP)) | ||||
| 		// Call gorecover with the FP of this frame. | ||||
| 		// FP is equal to caller's SP plus FixedFrameSize(). | ||||
| 		var fp ir.Node = mkcall("getcallersp", types.Types[types.TUINTPTR], init) | ||||
| 		if off := base.Ctxt.FixedFrameSize(); off != 0 { | ||||
| 			fp = ir.NewBinaryExpr(fp.Pos(), ir.OADD, fp, ir.NewInt(off)) | ||||
| 		} | ||||
| 		fp = ir.NewConvExpr(fp.Pos(), ir.OCONVNOP, types.NewPtr(types.Types[types.TINT32]), fp) | ||||
| 		return mkcall("gorecover", n.Type(), init, fp) | ||||
| 
 | ||||
| 	case ir.OCFUNC: | ||||
| 		return n | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Cherry Zhang
						Cherry Zhang