tests/fixedbugs: regression test for issue 100 (#129)

Adds a regression test based on klauspost/compress#186. This necessitated some related changes:

* Mark "RET" as a terminal instruction
* printer refactor to maintain compatibility with asmfmt
* Tweaks to other regression tests to ensure they are run correctly in CI

Updates #100 #65 #8
This commit is contained in:
Michael McLoughlin
2020-01-27 21:05:33 -08:00
committed by GitHub
parent 5a144d9b53
commit e089a6c93c
24 changed files with 11711 additions and 92 deletions

View File

@@ -0,0 +1,28 @@
Copyright (c) 2011 The Snappy-Go Authors. All rights reserved.
Copyright (c) 2019 Klaus Post. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -0,0 +1,11 @@
Regression test for [issue
#100](https://github.com/mmcloughlin/avo/issues/100) based on the original
reported allocation failure.
Based on the pull request
[`klauspost/compress#186`](https://github.com/klauspost/compress/pull/186) at
`c1f3cf132cd8e214b38cc16e418bf2e501ccda93` with the lines after `FIXME`
comments re-activated and other minimal edits to make it work in this
environment.
Original code covered by [BSD 3-Clause License](LICENSE).

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,9 @@
// Package allocfail is a regression test for issue 100 based on the original reported allocation failure.
//
// Based on the pull request https://github.com/klauspost/compress/pull/186 at
// c1f3cf132cd8e214b38cc16e418bf2e501ccda93 with the lines after "FIXME"
// comments re-activated and other minimal edits to make it work in this
// environment.
package allocfail
//go:generate go run asm.go -out allocfail.s -stubs stubs.go

View File

@@ -0,0 +1,85 @@
// Code generated by command: go run asm.go -out allocfail.s -stubs stubs.go. DO NOT EDIT.
// +build !appengine
// +build !noasm
// +build gc
package allocfail
// encodeBlockAsm encodes a non-empty src to a guaranteed-large-enough dst.
// It assumes that the varint-encoded length of the decompressed bytes has already been written.
//
//go:noescape
func encodeBlockAsm(dst []byte, src []byte) int
// encodeBlockAsm14B encodes a non-empty src to a guaranteed-large-enough dst.
// It assumes that the varint-encoded length of the decompressed bytes has already been written.
//
//go:noescape
func encodeBlockAsm14B(dst []byte, src []byte) int
// encodeBlockAsm12B encodes a non-empty src to a guaranteed-large-enough dst.
// It assumes that the varint-encoded length of the decompressed bytes has already been written.
//
//go:noescape
func encodeBlockAsm12B(dst []byte, src []byte) int
// encodeBlockAsmAvx encodes a non-empty src to a guaranteed-large-enough dst.
// It assumes that the varint-encoded length of the decompressed bytes has already been written.
//
//go:noescape
func encodeBlockAsmAvx(dst []byte, src []byte) int
// encodeBlockAsm14BAvx encodes a non-empty src to a guaranteed-large-enough dst.
// It assumes that the varint-encoded length of the decompressed bytes has already been written.
//
//go:noescape
func encodeBlockAsm14BAvx(dst []byte, src []byte) int
// encodeBlockAsm12BAvx encodes a non-empty src to a guaranteed-large-enough dst.
// It assumes that the varint-encoded length of the decompressed bytes has already been written.
//
//go:noescape
func encodeBlockAsm12BAvx(dst []byte, src []byte) int
// emitLiteral writes a literal chunk and returns the number of bytes written.
//
// It assumes that:
// dst is long enough to hold the encoded bytes
// 0 <= len(lit) && len(lit) <= math.MaxUint32
//
//go:noescape
func emitLiteral(dst []byte, lit []byte) int
// emitLiteralAvx writes a literal chunk and returns the number of bytes written.
//
// It assumes that:
// dst is long enough to hold the encoded bytes
// 0 <= len(lit) && len(lit) <= math.MaxUint32
//
//go:noescape
func emitLiteralAvx(dst []byte, lit []byte) int
// emitRepeat writes a repeat chunk and returns the number of bytes written.
// Length must be at least 4 and < 1<<32
//
//go:noescape
func emitRepeat(dst []byte, offset int, length int) int
// emitCopy writes a copy chunk and returns the number of bytes written.
//
// It assumes that:
// dst is long enough to hold the encoded bytes
// 1 <= offset && offset <= math.MaxUint32
// 4 <= length && length <= 1 << 24
//
//go:noescape
func emitCopy(dst []byte, offset int, length int) int
// matchLen returns how many bytes match in a and b
//
// It assumes that:
// len(a) <= len(b)
//
//go:noescape
func matchLen(a []byte, b []byte) int

View File

@@ -1,2 +0,0 @@
// Package issue100 contains a reproducer for a bug in aliased register allocation.
package issue100

View File

@@ -0,0 +1,2 @@
// Package minrepro contains a minimal reproducer for the aliased register allocation bug in issue 100.
package minrepro

View File

@@ -1,4 +1,4 @@
// Code generated by command: go run asm.go -out issue100.s -stubs stub.go. DO NOT EDIT.
// Code generated by command: go run asm.go -out minrepro.s -stubs stub.go. DO NOT EDIT.
#include "textflag.h"

View File

@@ -1,10 +1,10 @@
package issue100
package minrepro
import (
"testing"
)
//go:generate go run asm.go -out issue100.s -stubs stub.go
//go:generate go run asm.go -out minrepro.s -stubs stub.go
func TestIssue100(t *testing.T) {
n := uint64(100)

View File

@@ -0,0 +1,5 @@
// Code generated by command: go run asm.go -out minrepro.s -stubs stub.go. DO NOT EDIT.
package minrepro
func Issue100() uint64

View File

@@ -1,5 +0,0 @@
// Code generated by command: go run asm.go -out issue100.s -stubs stub.go. DO NOT EDIT.
package issue100
func Issue100() uint64

View File

@@ -1,11 +1,4 @@
// +build generate
//go:generate go run $GOFILE
// Regression test for a bug where casting a physical register would give the
// error "non physical register found".
//
// See: https://github.com/mmcloughlin/avo/issues/65#issuecomment-576850145
// +build ignore
package main

View File

@@ -0,0 +1,9 @@
// Package issue65 is a regression test for a bug involving casting physical registers.
//
// Regression test for a bug where casting a physical register would give the
// error "non physical register found".
//
// See: https://github.com/mmcloughlin/avo/issues/65#issuecomment-576850145
package issue65
//go:generate go run asm.go -out issue65.s -stubs stub.go

View File

@@ -0,0 +1,9 @@
// Code generated by command: go run asm.go -out issue65.s -stubs stub.go. DO NOT EDIT.
#include "textflag.h"
// func Issue65()
// Requires: AVX2
TEXT ·Issue65(SB), NOSPLIT, $0
VINSERTI128 $0x01, X0, Y1, Y2
RET

View File

@@ -0,0 +1,5 @@
// Code generated by command: go run asm.go -out issue65.s -stubs stub.go. DO NOT EDIT.
package issue65
func Issue65()