[llvm] 8905617 - [UpdateTestChecks] Use common ir function name matcher and extend to accept periods in names (PR37586)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 24 04:00:00 PDT 2020


Author: Simon Pilgrim
Date: 2020-03-24T10:59:30Z
New Revision: 8905617ee3acec9471c34afd6258d18de801ea29

URL: https://github.com/llvm/llvm-project/commit/8905617ee3acec9471c34afd6258d18de801ea29
DIFF: https://github.com/llvm/llvm-project/commit/8905617ee3acec9471c34afd6258d18de801ea29.diff

LOG: [UpdateTestChecks] Use common ir function name matcher and extend to accept periods in names (PR37586)

Remove the local versions of the IR_FUNCTION_RE matcher (they weren't doing anything different), and ensure all the function name matchers accept '.' and '-'.

We don't need to use '\.' inside python regex sets either, or '\-' as long as thats at the end of the set.

Added: 
    

Modified: 
    llvm/utils/UpdateTestChecks/common.py
    llvm/utils/update_analyze_test_checks.py
    llvm/utils/update_test_checks.py

Removed: 
    


################################################################################
diff  --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py
index 9dc42d46dc9f..3186628b50a2 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -67,16 +67,16 @@ def invoke_tool(exe, cmd_args, ir):
 UTC_ARGS_CMD = re.compile(r'.*' + UTC_ARGS_KEY + '\s*(?P<cmd>.*)\s*$')
 
 OPT_FUNCTION_RE = re.compile(
-    r'^\s*define\s+(?:internal\s+)?[^@]*@(?P<func>[\w-]+?)\s*'
-    r'(?P<args_and_sig>\((\)|(.*?[\w\.\-]+?)\))[^{]*)\{\n(?P<body>.*?)^\}$',
+    r'^\s*define\s+(?:internal\s+)?[^@]*@(?P<func>[\w.-]+?)\s*'
+    r'(?P<args_and_sig>\((\)|(.*?[\w.-]+?)\))[^{]*)\{\n(?P<body>.*?)^\}$',
     flags=(re.M | re.S))
 
 ANALYZE_FUNCTION_RE = re.compile(
-    r'^\s*\'(?P<analysis>[\w\s-]+?)\'\s+for\s+function\s+\'(?P<func>[\w-]+?)\':'
+    r'^\s*\'(?P<analysis>[\w\s-]+?)\'\s+for\s+function\s+\'(?P<func>[\w.-]+?)\':'
     r'\s*\n(?P<body>.*)$',
     flags=(re.X | re.S))
 
-IR_FUNCTION_RE = re.compile(r'^\s*define\s+(?:internal\s+)?[^@]*@([\w.]+)\s*\(')
+IR_FUNCTION_RE = re.compile(r'^\s*define\s+(?:internal\s+)?[^@]*@([\w.-]+)\s*\(')
 TRIPLE_IR_RE = re.compile(r'^\s*target\s+triple\s*=\s*"([^"]+)"$')
 TRIPLE_ARG_RE = re.compile(r'-mtriple[= ]([^ ]+)')
 MARCH_ARG_RE = re.compile(r'-march[= ]([^ ]+)')
@@ -215,7 +215,7 @@ def build_function_body_dictionary(function_re, scrubber, scrubber_args, raw_too
 
 # Match things that look at identifiers, but only if they are followed by
 # spaces, commas, paren, or end of the string
-IR_VALUE_RE = re.compile(r'(\s+)%([\w\.\-]+?)([,\s\(\)]|\Z)')
+IR_VALUE_RE = re.compile(r'(\s+)%([\w.-]+?)([,\s\(\)]|\Z)')
 
 # Create a FileCheck variable name based on an IR name.
 def get_value_name(var):

diff  --git a/llvm/utils/update_analyze_test_checks.py b/llvm/utils/update_analyze_test_checks.py
index e3b6dfdf620c..2f1a84297642 100755
--- a/llvm/utils/update_analyze_test_checks.py
+++ b/llvm/utils/update_analyze_test_checks.py
@@ -45,10 +45,6 @@
 
 ADVERT = '; NOTE: Assertions have been autogenerated by '
 
-# RegEx: this is where the magic happens.
-
-IR_FUNCTION_RE = re.compile('^\s*define\s+(?:internal\s+)?[^@]*@([\w-]+)\s*\(')
-
 def main():
   from argparse import RawTextHelpFormatter
   parser = argparse.ArgumentParser(description=__doc__, formatter_class=RawTextHelpFormatter)
@@ -168,7 +164,7 @@ def main():
       # If it's outside a function, it just gets copied to the output.
       output_lines.append(input_line)
 
-      m = IR_FUNCTION_RE.match(input_line)
+      m = common.IR_FUNCTION_RE.match(input_line)
       if not m:
         continue
       func_name = m.group(1)

diff  --git a/llvm/utils/update_test_checks.py b/llvm/utils/update_test_checks.py
index f6fee1437f5d..014b55c9ae83 100755
--- a/llvm/utils/update_test_checks.py
+++ b/llvm/utils/update_test_checks.py
@@ -45,14 +45,6 @@
 
 ADVERT = '; NOTE: Assertions have been autogenerated by '
 
-# RegEx: this is where the magic happens.
-
-IR_FUNCTION_RE = re.compile('^\s*define\s+(?:internal\s+)?[^@]*@([\w-]+)\s*\(')
-
-
-
-
-
 def main():
   from argparse import RawTextHelpFormatter
   parser = argparse.ArgumentParser(description=__doc__, formatter_class=RawTextHelpFormatter)
@@ -203,7 +195,7 @@ def main():
       # If it's outside a function, it just gets copied to the output.
       output_lines.append(input_line)
 
-      m = IR_FUNCTION_RE.match(input_line)
+      m = common.IR_FUNCTION_RE.match(input_line)
       if not m:
         continue
       func_name = m.group(1)


        


More information about the llvm-commits mailing list