diff options
| author | Josh Bleecher Snyder <josharian@gmail.com> | 2020-01-22 09:59:24 -0800 |
|---|---|---|
| committer | Josh Bleecher Snyder <josharian@gmail.com> | 2020-02-21 04:25:16 +0000 |
| commit | 60651a1bc8540d9144e69fc71065f4994dfb0bbc (patch) | |
| tree | 13969d3ac974cc9d036744ff93465b8e3afbfdc1 /src | |
| parent | 6dd11bcb35cba37f5994c1b9aaaf7d2dc13fd7cf (diff) | |
| download | go-60651a1bc8540d9144e69fc71065f4994dfb0bbc.tar.xz | |
cmd/compile: add rule location to some rulegen logging
This requires threading location information through varCount.
This provides much more useful error messages.
Change-Id: If5ff942cbbbf386724eda15a523c181c137fac20
Reviewed-on: https://go-review.googlesource.com/c/go/+/216221
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martà <mvdan@mvdan.cc>
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/compile/internal/ssa/gen/rulegen.go | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/cmd/compile/internal/ssa/gen/rulegen.go b/src/cmd/compile/internal/ssa/gen/rulegen.go index 2e5f3d24f3..0d51458f60 100644 --- a/src/cmd/compile/internal/ssa/gen/rulegen.go +++ b/src/cmd/compile/internal/ssa/gen/rulegen.go @@ -945,13 +945,13 @@ func genBlockRewrite(rule Rule, arch arch, data blockData) *RuleRewrite { // genMatch returns the variable whose source position should be used for the // result (or "" if no opinion), and a boolean that reports whether the match can fail. func genMatch(rr *RuleRewrite, arch arch, match string, pregenTop bool) (pos, checkOp string) { - cnt := varCount(rr.match, rr.cond) + cnt := varCount(rr) return genMatch0(rr, arch, match, "v", cnt, pregenTop) } func genMatch0(rr *RuleRewrite, arch arch, match, v string, cnt map[string]int, pregenTop bool) (pos, checkOp string) { if match[0] != '(' || match[len(match)-1] != ')' { - log.Fatalf("non-compound expr in genMatch0: %q", match) + log.Fatalf("%s: non-compound expr in genMatch0: %q", rr.loc, match) } op, oparch, typ, auxint, aux, args := parseValue(match, arch, rr.loc) @@ -1443,14 +1443,14 @@ func expandOr(r string) []string { } // varCount returns a map which counts the number of occurrences of -// Value variables in the s-expression "match" and the Go expression "cond". -func varCount(match, cond string) map[string]int { +// Value variables in the s-expression rr.match and the Go expression rr.cond. +func varCount(rr *RuleRewrite) map[string]int { cnt := map[string]int{} - varCount1(match, cnt) - if cond != "" { - expr, err := parser.ParseExpr(cond) + varCount1(rr.loc, rr.match, cnt) + if rr.cond != "" { + expr, err := parser.ParseExpr(rr.cond) if err != nil { - log.Fatalf("failed to parse cond %q: %v", cond, err) + log.Fatalf("%s: failed to parse cond %q: %v", rr.loc, rr.cond, err) } ast.Inspect(expr, func(n ast.Node) bool { if id, ok := n.(*ast.Ident); ok { @@ -1462,7 +1462,7 @@ func varCount(match, cond string) map[string]int { return cnt } -func varCount1(m string, cnt map[string]int) { +func varCount1(loc, m string, cnt map[string]int) { if m[0] == '<' || m[0] == '[' || m[0] == '{' { return } @@ -1476,11 +1476,11 @@ func varCount1(m string, cnt map[string]int) { cnt[name]++ } if expr[0] != '(' || expr[len(expr)-1] != ')' { - log.Fatalf("non-compound expr in commute1: %q", expr) + log.Fatalf("%s: non-compound expr in varCount1: %q", loc, expr) } s := split(expr[1 : len(expr)-1]) for _, arg := range s[1:] { - varCount1(arg, cnt) + varCount1(loc, arg, cnt) } } |
