nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: mmcloughlin/avo
Pull request #115 (2020-01-13 17:11:38)

"instruction should follow a label" info
Add the label in question to the error message.

I am not a huge fan of this error in general, but at least some info would be nice.


Patch:
diff --git a/internal/prnt/printer.go b/internal/prnt/printer.go
index 2239946..410895c 100644
--- a/internal/prnt/printer.go
+++ b/internal/prnt/printer.go
@@ -5,6 +5,7 @@ import (
 	"bytes"
 	"fmt"
 	"io"
+	"strings"
 )
 
 // Generator provides convenience methods for code generators. In particular it
@@ -38,7 +39,8 @@ func (g *Generator) NL() {
 // Comment writes comment lines prefixed with "// ".
 func (g *Generator) Comment(lines ...string) {
 	for _, line := range lines {
-		g.Printf("// %s\n", line)
+		line = strings.TrimSpace("// " + line)
+		g.Printf("%s\n", line)
 	}
 }
 
diff --git a/pass/cfg.go b/pass/cfg.go
index 198208d..d8e8fd4 100644
--- a/pass/cfg.go
+++ b/pass/cfg.go
@@ -17,7 +17,7 @@ func LabelTarget(fn *ir.Function) error {
 		switch n := node.(type) {
 		case ir.Label:
 			if pending != empty {
-				return errors.New("instruction should follow a label")
+				return fmt.Errorf("expected instruction following label %q", pending)
 			}
 			pending = n
 			if _, found := target[pending]; found {


Test patch:
diff --git a/pass/cfg_test.go b/pass/cfg_test.go
index 42f1004..5dc8857 100644
--- a/pass/cfg_test.go
+++ b/pass/cfg_test.go
@@ -66,7 +66,7 @@ func TestLabelTargetInstructionFollowLabel(t *testing.T) {
 
 	err := LabelTarget(f)
 
-	if err == nil || err.Error() != "instruction should follow a label" {
+	if err == nil || err.Error() != "expected instruction following label \"lblA\"" {
 		t.Fatalf("expected error when label is not followed by instruction; got %v", err)
 	}
 }
Repository: mmcloughlin/avo
Pull request #182 (2021-04-16 02:34:08)

Allow signed immediates to be matched by IsIMMX functions
This has been such a great library for us! But we've been working around an issue concerning immediates that this PR should address. Many of the instruction functions correctly match the size of immediate values, but they only accept unsigned immediates. For example:

```go
r := GP64()
ANDQ(I8(-32), r)   // ANDQ: bad operands
```

While the `imm8` input is checked as expected, the `operand.IsIMM8()` function is causing this check to incorrectly fail.

I believe this PR should address issue #181 


Patch:
diff --git a/operand/checks.go b/operand/checks.go
index 2585479..28de231 100644
--- a/operand/checks.go
+++ b/operand/checks.go
@@ -35,26 +35,30 @@ func IsIMM2U(op Op) bool {
 
 // IsIMM8 returns true is op is an 8-bit immediate.
 func IsIMM8(op Op) bool {
-	_, ok := op.(U8)
-	return ok
+	_, uok := op.(U8)
+	_, iok := op.(I8)
+	return uok || iok
 }
 
 // IsIMM16 returns true is op is a 16-bit immediate.
 func IsIMM16(op Op) bool {
-	_, ok := op.(U16)
-	return ok
+	_, uok := op.(U16)
+	_, iok := op.(I16)
+	return uok || iok
 }
 
 // IsIMM32 returns true is op is a 32-bit immediate.
 func IsIMM32(op Op) bool {
-	_, ok := op.(U32)
-	return ok
+	_, uok := op.(U32)
+	_, iok := op.(I32)
+	return uok || iok
 }
 
 // IsIMM64 returns true is op is a 64-bit immediate.
 func IsIMM64(op Op) bool {
-	_, ok := op.(U64)
-	return ok
+	_, uok := op.(U64)
+	_, iok := op.(I64)
+	return uok || iok
 }
 
 // IsAL returns true if op is the AL register.


Test patch:
diff --git a/operand/checks_test.go b/operand/checks_test.go
index f6821ed..1d35df5 100644
--- a/operand/checks_test.go
+++ b/operand/checks_test.go
@@ -36,6 +36,12 @@ func TestChecks(t *testing.T) {
 
 		{IsIMM64, Imm((1 << 64) - 1), true},
 
+		// Signed Immediates
+		{IsIMM8, I8(-1), true},
+		{IsIMM16, I16(-1), true},
+		{IsIMM32, I32(-1), true},
+		{IsIMM64, I64(-1), true},
+
 		// Specific registers
 		{IsAL, reg.AL, true},
 		{IsAL, reg.CL, false},