[PATCH] D28384: Update update_test_checks to work properly with phi nodes and other fun things.

bryant via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 6 12:21:56 PST 2017


bryant added inline comments.


================
Comment at: utils/update_test_checks.py:73
+# spaces, commas, paren, or end of the string
+IR_VALUE_RE = re.compile(r'(\s+)%(.+?)([,\s\(\)]|\Z)')
 
----------------
How come you added more capture groups? Isn't this the syntax that you're expecting?

FILE ::== LINE*
LINE ::== LINE_ENT+
LINE_ENT ::== IR_VALUE | INTERVENING_STUFF

And the purpose of all this is to capture and rename IR_VALUEs, right?


================
Comment at: utils/update_test_checks.py:175
 def genericize_check_lines(lines):
+  global vars_seen
   lines_with_def = []
----------------
Is there a reason for moving vars_seen to the top level scope? I don't think that `global` is needed.

```
def generic_check(lines):
    vars_seen = set()

    def ssaify(match):
        v = match.group(1)
        if v in vars_seen:
            rv = get_value_use(v)
        else:
            vars_seen.add(v) # this works just fine.
            rv = get_value_definition(v)
        return the new match which is match.group(1) in the previous IR_VALUE_RE
```

Global would only be needed if you're reassigning the variable vars_seen, whereas the update here is done with a method call.


https://reviews.llvm.org/D28384





More information about the llvm-commits mailing list