[dev.ssa] cmd/compile: use function calls instead of special ops for panics

There's no need for special ops for panicindex and panicslice.
Just use regular runtime calls.

Change-Id: I71b9b73f4f1ebce1220fdc1e7b7f65cfcf4b7bae
Reviewed-on: https://go-review.googlesource.com/14726
Reviewed-by: David Chase <drchase@google.com>
diff --git a/src/cmd/compile/internal/gc/ssa.go b/src/cmd/compile/internal/gc/ssa.go
index 4b71d1f..b9da5ed 100644
--- a/src/cmd/compile/internal/gc/ssa.go
+++ b/src/cmd/compile/internal/gc/ssa.go
@@ -2312,7 +2312,7 @@
 
 	// bounds check
 	cmp := s.newValue2(ssa.OpIsInBounds, Types[TBOOL], idx, len)
-	s.check(cmp, ssa.OpPanicIndexCheck)
+	s.check(cmp, Panicindex)
 }
 
 // sliceBoundsCheck generates slice bounds checking code.  Checks if 0 <= idx <= len, branches to exit if not.
@@ -2326,11 +2326,11 @@
 
 	// bounds check
 	cmp := s.newValue2(ssa.OpIsSliceInBounds, Types[TBOOL], idx, len)
-	s.check(cmp, ssa.OpPanicSliceCheck)
+	s.check(cmp, panicslice)
 }
 
-// If cmp (a bool) is true, panic using the given op.
-func (s *state) check(cmp *ssa.Value, panicOp ssa.Op) {
+// If cmp (a bool) is true, panic using the given function.
+func (s *state) check(cmp *ssa.Value, fn *Node) {
 	b := s.endBlock()
 	b.Kind = ssa.BlockIf
 	b.Control = cmp
@@ -2340,12 +2340,10 @@
 	b.AddEdgeTo(bNext)
 	b.AddEdgeTo(bPanic)
 	s.startBlock(bPanic)
-	// The panic check takes/returns memory to ensure that the right
+	// The panic call takes/returns memory to ensure that the right
 	// memory state is observed if the panic happens.
-	chk := s.newValue1(panicOp, ssa.TypeMem, s.mem())
-	s.endBlock()
-	bPanic.Kind = ssa.BlockExit
-	bPanic.Control = chk
+	s.rtcall(fn, false, nil)
+
 	s.startBlock(bNext)
 }
 
@@ -3700,16 +3698,6 @@
 		q.From.Reg = x86.REG_AX
 		q.To.Type = obj.TYPE_MEM
 		q.To.Reg = r
-	case ssa.OpAMD64LoweredPanicIndexCheck:
-		p := Prog(obj.ACALL)
-		p.To.Type = obj.TYPE_MEM
-		p.To.Name = obj.NAME_EXTERN
-		p.To.Sym = Linksym(Panicindex.Sym)
-	case ssa.OpAMD64LoweredPanicSliceCheck:
-		p := Prog(obj.ACALL)
-		p.To.Type = obj.TYPE_MEM
-		p.To.Name = obj.NAME_EXTERN
-		p.To.Sym = Linksym(panicslice.Sym)
 	case ssa.OpAMD64LoweredGetG:
 		r := regnum(v)
 		// See the comments in cmd/internal/obj/x86/obj6.go