[PATCH] D80584: [utils] change update_test_checks.py use of 'TMP' value names

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 26 13:05:50 PDT 2020


spatel created this revision.
spatel added reviewers: qcolombet, lebedev.ri, RKSimon.
Herald added subscribers: arichardson, mcrosier.
Herald added a project: LLVM.

As discussed in PR45951:
https://bugs.llvm.org/show_bug.cgi?id=45951

There's a potential name collision between -instnamer and/or manually-generated IR test files with update_test_checks.py because all of them try to use the variable name that should never be used: "tmp".

This patch proposes to reduce the odds of collision and adds a warning if we detect the problem. This will cause regression test churn when regenerating CHECK lines on existing files. We could do a mass update to get that out of the way all at once if that seems better.


https://reviews.llvm.org/D80584

Files:
  llvm/utils/UpdateTestChecks/common.py


Index: llvm/utils/UpdateTestChecks/common.py
===================================================================
--- llvm/utils/UpdateTestChecks/common.py
+++ llvm/utils/UpdateTestChecks/common.py
@@ -218,10 +218,12 @@
 # spaces, commas, paren, or end of the string
 IR_VALUE_RE = re.compile(r'(\s+)%([\w.-]+?)([,\s\(\)]|\Z)')
 
+NAMELESS_PREFIX = "NAMELESS"
+
 # Create a FileCheck variable name based on an IR name.
 def get_value_name(var):
   if var.isdigit():
-    var = 'TMP' + var
+    var = NAMELESS_PREFIX + var
   var = var.replace('.', '_')
   var = var.replace('-', '_')
   return var.upper()
@@ -243,6 +245,8 @@
   # into defs, and variables we have seen into uses.
   def transform_line_vars(match):
     var = match.group(2)
+    if NAMELESS_PREFIX.lower() in var.lower():
+      warn("Change IR value name '%s' to prevent possible conflict with scripted FileCheck name." % (var,))
     if var in vars_seen:
       rv = get_value_use(var)
     else:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80584.266301.patch
Type: text/x-patch
Size: 965 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200526/2b3daff0/attachment.bin>


More information about the llvm-commits mailing list