From e54e9781a4e043b3140b0c908ba4f4e469fd317e Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sun, 26 Apr 2020 14:14:14 +0200 Subject: prog: remove Dir from Type Having Dir is Type is handy, but forces us to duplicate lots of types. E.g. if a struct is referenced as both in and out, then we need to have 2 copies and 2 copies of structs/types it includes. If also prevents us from having the struct type as struct identity (because we can have up to 3 of them). Revert to the old way we used to do it: propagate Dir as we walk syscall arguments. This moves lots of dir passing from pkg/compiler to prog package. Now Arg contains the dir, so once we build the tree, we can use dirs as before. Reduces size of sys/linux/gen/amd64.go from 6058336 to 5661150 (-6.6%). Update #1580 --- prog/hints_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'prog/hints_test.go') diff --git a/prog/hints_test.go b/prog/hints_test.go index 0fc9afa02..caf84e715 100644 --- a/prog/hints_test.go +++ b/prog/hints_test.go @@ -157,7 +157,7 @@ func TestHintsCheckConstArg(t *testing.T) { typ := &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{ TypeSize: test.size}, BitfieldLen: test.bitsize}} - constArg := MakeConstArg(typ, test.in) + constArg := MakeConstArg(typ, DirIn, test.in) checkConstArg(constArg, test.comps, func() { res = append(res, constArg.Val) }) @@ -295,8 +295,8 @@ func TestHintsCheckDataArg(t *testing.T) { res := make(map[string]bool) // Whatever type here. It's just needed to pass the // dataArg.Type().Dir() == DirIn check. - typ := &ArrayType{TypeCommon{"", "", 0, DirIn, false, true}, nil, 0, 0, 0} - dataArg := MakeDataArg(typ, []byte(test.in)) + typ := &ArrayType{TypeCommon{"", "", 0, false, true}, nil, 0, 0, 0} + dataArg := MakeDataArg(typ, DirIn, []byte(test.in)) checkDataArg(dataArg, test.comps, func() { res[string(dataArg.Data())] = true }) @@ -499,7 +499,7 @@ func TestHintsRandom(t *testing.T) { func extractValues(c *Call) map[uint64]bool { vals := make(map[uint64]bool) ForeachArg(c, func(arg Arg, _ *ArgCtx) { - if typ := arg.Type(); typ == nil || typ.Dir() == DirOut { + if arg.Dir() == DirOut { return } switch a := arg.(type) { -- cgit mrf-deployment