p.To.Reg = v.Args[0].Reg()
ssagen.AddAux2(&p.To, v, sc.Off64())
case ssa.OpAMD64MOVOstorezero:
- if s.ABI != obj.ABIInternal {
- v.Fatalf("MOVOstorezero can be only used in ABIInternal functions")
- }
- if !objabi.Experiment.RegabiG {
+ if !objabi.Experiment.RegabiG || s.ABI != obj.ABIInternal {
// zero X15 manually
opregreg(s, x86.AXORPS, x86.REG_X15, x86.REG_X15)
}
p.To.Type = obj.TYPE_REG
p.To.Reg = v.Reg()
case ssa.OpAMD64DUFFZERO:
- if s.ABI != obj.ABIInternal {
- v.Fatalf("MOVOconst can be only used in ABIInternal functions")
- }
- if !objabi.Experiment.RegabiG {
+ if !objabi.Experiment.RegabiG || s.ABI != obj.ABIInternal {
// zero X15 manually
opregreg(s, x86.AXORPS, x86.REG_X15, x86.REG_X15)
}
// Closure pointer is DX.
ssagen.CheckLoweredGetClosurePtr(v)
case ssa.OpAMD64LoweredGetG:
- if objabi.Experiment.RegabiG {
- v.Fatalf("LoweredGetG should not appear in new ABI")
+ if objabi.Experiment.RegabiG && s.ABI == obj.ABIInternal {
+ v.Fatalf("LoweredGetG should not appear in ABIInternal")
}
r := v.Reg()
getgFromTLS(s, r)
(IsInBounds idx len) => (SETB (CMPQ idx len))
(IsSliceInBounds idx len) => (SETBE (CMPQ idx len))
(NilCheck ...) => (LoweredNilCheck ...)
-(GetG mem) && !objabi.Experiment.RegabiG => (LoweredGetG mem) // only lower in old ABI. in new ABI we have a G register.
+(GetG mem) && !(objabi.Experiment.RegabiG && v.Block.Func.OwnAux.Fn.ABI() == obj.ABIInternal) => (LoweredGetG mem) // only lower in old ABI. in new ABI we have a G register.
(GetClosurePtr ...) => (LoweredGetClosurePtr ...)
(GetCallerPC ...) => (LoweredGetCallerPC ...)
(GetCallerSP ...) => (LoweredGetCallerSP ...)
package ssa
import "math"
+import "cmd/internal/obj"
import "cmd/internal/objabi"
import "cmd/compile/internal/types"
func rewriteValueAMD64_OpGetG(v *Value) bool {
v_0 := v.Args[0]
// match: (GetG mem)
- // cond: !objabi.Experiment.RegabiG
+ // cond: !(objabi.Experiment.RegabiG && v.Block.Func.OwnAux.Fn.ABI() == obj.ABIInternal)
// result: (LoweredGetG mem)
for {
mem := v_0
- if !(!objabi.Experiment.RegabiG) {
+ if !(!(objabi.Experiment.RegabiG && v.Block.Func.OwnAux.Fn.ABI() == obj.ABIInternal)) {
break
}
v.reset(OpAMD64LoweredGetG)
fn.ABI = defABI
}
+ if fn.Pragma&ir.CgoUnsafeArgs != 0 {
+ // CgoUnsafeArgs indicates the function (or its callee) uses
+ // offsets to dispatch arguments, which currently using ABI0
+ // frame layout. Pin it to ABI0.
+ fn.ABI = obj.ABI0
+ }
+
// Apply references.
if abis, ok := s.refs[symName]; ok {
fn.ABIRefs |= abis