Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing: extend tests for register allocator #43

Open
mmcloughlin opened this issue Jan 7, 2019 · 1 comment
Open

testing: extend tests for register allocator #43

mmcloughlin opened this issue Jan 7, 2019 · 1 comment
Labels
good first issue Good for newcomers testing Tests and supporting infrastructure

Comments

@mmcloughlin
Copy link
Owner

We are reliant primarily on the examples for testing at this point. It would be good to "stress" the allocator because I would be (pleasantly) surprised if it's bug-free.

  • More extensive unit testing
  • Integration test under tests/ that (for example) uses the max number of registers of a given kind and confirms the register allocator doesn't fall over
  • More specifically, handling of "casting" is a little ugly. It would be good to have a test that stresses this specifically. Perhaps, something that allocates 16 virtual general purpose registers and then accesses all sub-registers. This is clearly a possible allocation, but I could imagine the allocator messing up.
  • I'm sure other tests will come to mind

Unit tests right now are trivial:

avo/pass/alloc_test.go

Lines 9 to 46 in 7752262

func TestAllocatorSimple(t *testing.T) {
c := reg.NewCollection()
x, y := c.XMM(), c.YMM()
a, err := NewAllocatorForKind(reg.KindVector)
if err != nil {
t.Fatal(err)
}
a.Add(x)
a.Add(y)
a.AddInterference(x, y)
alloc, err := a.Allocate()
if err != nil {
t.Fatal(err)
}
t.Log(alloc)
if alloc[x] != reg.X0 || alloc[y] != reg.Y1 {
t.Fatalf("unexpected allocation")
}
}
func TestAllocatorImpossible(t *testing.T) {
a, err := NewAllocatorForKind(reg.KindVector)
if err != nil {
t.Fatal(err)
}
a.AddInterference(reg.X7, reg.Z7)
_, err = a.Allocate()
if err == nil {
t.Fatal("expected allocation error")
}
}

@mmcloughlin mmcloughlin added good first issue Good for newcomers testing Tests and supporting infrastructure labels Jan 7, 2019
@mmcloughlin
Copy link
Owner Author

See #65 for an apparent problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers testing Tests and supporting infrastructure
Projects
None yet
Development

No branches or pull requests

1 participant