Commit 644c16c7 authored by Cherry Zhang's avatar Cherry Zhang

cmd/compile: fix intrinsifying sync/atomic.Swap* on AMD64

It should alias to Xchg instead of Swap. Found when testing #16985.

Change-Id: If9fd734a1f89b8b2656f421eb31b9d1b0d95a49f
Reviewed-on: https://go-review.googlesource.com/28512
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarKeith Randall <khr@golang.org>
parent f1ef5a06
......@@ -2706,17 +2706,17 @@ func intrinsicInit() {
i.std[intrinsicKey{"runtime/internal/atomic", "Store64"}]
i.std[intrinsicKey{"sync/atomic", "SwapInt32"}] =
i.std[intrinsicKey{"runtime/internal/atomic", "Swap"}]
i.std[intrinsicKey{"runtime/internal/atomic", "Xchg"}]
i.std[intrinsicKey{"sync/atomic", "SwapInt64"}] =
i.std[intrinsicKey{"runtime/internal/atomic", "Swap64"}]
i.std[intrinsicKey{"runtime/internal/atomic", "Xchg64"}]
i.std[intrinsicKey{"sync/atomic", "SwapUint32"}] =
i.std[intrinsicKey{"runtime/internal/atomic", "Swap"}]
i.std[intrinsicKey{"runtime/internal/atomic", "Xchg"}]
i.std[intrinsicKey{"sync/atomic", "SwapUint64"}] =
i.std[intrinsicKey{"runtime/internal/atomic", "Swap64"}]
i.std[intrinsicKey{"runtime/internal/atomic", "Xchg64"}]
i.ptrSized[sizedIntrinsicKey{"sync/atomic", "SwapUintptr", 4}] =
i.std[intrinsicKey{"runtime/internal/atomic", "Swap"}]
i.std[intrinsicKey{"runtime/internal/atomic", "Xchg"}]
i.ptrSized[sizedIntrinsicKey{"sync/atomic", "SwapUintptr", 8}] =
i.std[intrinsicKey{"runtime/internal/atomic", "Swap64"}]
i.std[intrinsicKey{"runtime/internal/atomic", "Xchg64"}]
i.std[intrinsicKey{"sync/atomic", "CompareAndSwapInt32"}] =
i.std[intrinsicKey{"runtime/internal/atomic", "Cas"}]
......
// +build amd64
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import "sync/atomic"
var x uint32
func atomics() {
_ = atomic.LoadUint32(&x) // ERROR "intrinsic substitution for LoadUint32"
atomic.StoreUint32(&x, 1) // ERROR "intrinsic substitution for StoreUint32"
atomic.AddUint32(&x, 1) // ERROR "intrinsic substitution for AddUint32"
atomic.SwapUint32(&x, 1) // ERROR "intrinsic substitution for SwapUint32"
atomic.CompareAndSwapUint32(&x, 1, 2) // ERROR "intrinsic substitution for CompareAndSwapUint32"
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment