1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

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

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

There's a potential name collision between update_test_checks.py and -instnamer
and/or manually-generated IR test files 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.

Differential Revision: https://reviews.llvm.org/D80584
This commit is contained in:
Sanjay Patel 2020-05-31 10:46:11 -04:00
parent 5e9f292d99
commit 2ca9a76699

View File

@ -218,10 +218,12 @@ SCRUB_IR_COMMENT_RE = re.compile(r'\s*;.*')
# 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 @@ def genericize_check_lines(lines, is_analyze, vars_seen):
# 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: