Skip to content

Commit

Permalink
fix: skip cs nopw 0x0(%rax,%rax,1)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenghaoz committed Jul 15, 2023
1 parent 77e86ab commit 852183b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,21 @@ jobs:
- name: Run tests
run: go test -v ./...
working-directory: example

cases:
name: cases
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v4
- name: Install clang
uses: ConorMacBride/install-package@v1
with:
apt: clang libc6-dev-i386
- name: Install GOAT
run: go install .
- name: Run tests
run: |
for file in tests/*.c
goat $file -O3 -mavx -mfma
done
6 changes: 4 additions & 2 deletions parser_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ package main
import (
"bufio"
"fmt"
"github.com/klauspost/asmfmt"
"os"
"regexp"
"strings"
"unicode"

"github.com/klauspost/asmfmt"
)

const buildTags = "//go:build !noasm && amd64\n"
Expand Down Expand Up @@ -163,7 +164,8 @@ func parseObjectDump(dump string, functions map[string][]Line) error {
if assembly == "" {
return fmt.Errorf("try to increase --insn-width of objdump")
} else if strings.HasPrefix(assembly, "nop") ||
assembly == "xchg %ax,%ax" {
assembly == "xchg %ax,%ax" ||
assembly == "cs nopw 0x0(%rax,%rax,1)" {
continue
}
if lineNumber >= len(functions[functionName]) {
Expand Down
15 changes: 15 additions & 0 deletions tests/cs_npw.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
void l2(float *a, float *b, float *res, long *len)
{
int size = *len;

float sum = 0;
// add the remaining vectors
for (int i = 0; i < size; i++)
{
float diff = a[i] - b[i];
float sq = diff * diff;
sum += sq;
}

*res = sum;
}

0 comments on commit 852183b

Please sign in to comment.