[PATCH] D43604: [utils] fixing update_mir_test_checks.py's language (mir/IR/etc) detection
Roman Tereshin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 21 17:15:08 PST 2018
rtereshin created this revision.
rtereshin added a reviewer: bogner.
Herald added a subscriber: javed.absar.
Adding a little more robust language detection for utils/update_mir_test_checks.py parsing it from `-x <LANG>` arg of llc if it's not obvious from the test file name.
This patch is dependent upon https://reviews.llvm.org/D43603
Repository:
rL LLVM
https://reviews.llvm.org/D43604
Files:
test/CodeGen/AArch64/test-update_mir_test_checks.py-itself.mir
utils/update_mir_test_checks.py
Index: utils/update_mir_test_checks.py
===================================================================
--- utils/update_mir_test_checks.py
+++ utils/update_mir_test_checks.py
@@ -29,6 +29,7 @@
RUN_LINE_RE = re.compile('^\s*[;#]\s*RUN:\s*(.*)$')
TRIPLE_ARG_RE = re.compile(r'-mtriple[= ]([^ ]+)')
MARCH_ARG_RE = re.compile(r'-march[= ]([^ ]+)')
+LANG_ARG_RE = re.compile(r'-x[= ]([^ ]+)')
TRIPLE_IR_RE = re.compile(r'^\s*target\s+triple\s*=\s*"([^"]+)"$')
CHECK_PREFIX_RE = re.compile('--?check-prefix(?:es)?[= ](\S+)')
CHECK_RE = re.compile(r'^\s*[;#]\s*([^:]+?)(?:-NEXT|-NOT|-DAG|-LABEL)?:')
@@ -74,10 +75,11 @@
class Run:
- def __init__(self, prefixes, cmd_args, triple):
+ def __init__(self, prefixes, cmd_args, triple, lang):
self.prefixes = prefixes
self.cmd_args = cmd_args
self.triple = triple
+ self.lang = lang
def __getitem__(self, index):
return [self.prefixes, self.cmd_args, self.triple][index]
@@ -143,6 +145,9 @@
if m and not triple:
triple = '{}--'.format(m.group(1))
+ m = LANG_ARG_RE.search(llc_cmd)
+ lang = (m.group(1) if m else test.split('.')[-1]).lower()
+
cmd_args = llc_cmd[len('llc'):].strip()
cmd_args = cmd_args.replace('< %s', '').replace('%s', '').strip()
@@ -152,7 +157,7 @@
check_prefixes = ['CHECK']
all_prefixes += check_prefixes
- run_list.append(Run(check_prefixes, cmd_args, triple))
+ run_list.append(Run(check_prefixes, cmd_args, triple, lang))
# Remove any common prefixes. We'll just leave those entirely alone.
common_prefixes = set([prefix for prefix in all_prefixes
@@ -344,7 +349,7 @@
warn('Ignoring common prefixes: {}'.format(common_prefixes),
test_file=test)
- comment_char = '#' if test.endswith('.mir') else ';'
+ comment_char = '#' if any(run.lang == 'mir' for run in run_list) else ';'
autogenerated_note = ('{} NOTE: Assertions have been autogenerated by '
'utils/{}'.format(comment_char,
os.path.basename(__file__)))
Index: test/CodeGen/AArch64/test-update_mir_test_checks.py-itself.mir
===================================================================
--- test/CodeGen/AArch64/test-update_mir_test_checks.py-itself.mir
+++ test/CodeGen/AArch64/test-update_mir_test_checks.py-itself.mir
@@ -13,6 +13,9 @@
# STDERR-SAME: sed -e {{.*}} RUN-NESTED{{.*}}SOURCE{{.*}}STDERR{{.*}}SOURCE
# STDERR-NOT: WARNING
+# SOURCE-LABEL: # NOTE: Assertions have been autogenerated by
+# SOURCE-SAME: utils/update_mir_test_checks.py
+#
# SOURCE: WARNING
# SOURCE-NEXT: WARNING
# SOURCE-NEXT: sed
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43604.135350.patch
Type: text/x-patch
Size: 2742 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180222/f613263b/attachment.bin>
More information about the llvm-commits
mailing list