[utils] Stricter checking from update_mca_test_checks.py
authorGreg Bedwell <greg_bedwell@sn.scee.net>
Fri, 28 Sep 2018 15:39:09 +0000 (15:39 +0000)
committerGreg Bedwell <greg_bedwell@sn.scee.net>
Fri, 28 Sep 2018 15:39:09 +0000 (15:39 +0000)
If any prefixes have been specified on the RUN lines that do not end up
ever actually getting printed, raise an Error. This is either an
indication that the run lines just need cleaning up, or that something
is more fundamentally wrong with the test.

Also raise an Error if there are any blocks which cannot be checked
because they are not uniquely covered by a prefix.

Fixed up a couple of tests where the extra checking flagged up issues.

Differential Revision: https://reviews.llvm.org/D48276

llvm-svn: 343332

llvm/test/tools/llvm-mca/X86/option-all-views-2.s
llvm/test/tools/llvm-mca/X86/register-file-statistics.s
llvm/utils/update_mca_test_checks.py

index 54b269d..66eb3bb 100644 (file)
@@ -3,7 +3,7 @@
 # RUN: llvm-mca -mtriple=x86_64-unknown-unknown -mcpu=btver2 -all-views -resource-pressure       < %s | FileCheck %s -check-prefix=ALL -check-prefix=FULLREPORT
 # RUN: llvm-mca -mtriple=x86_64-unknown-unknown -mcpu=btver2 -resource-pressure -all-views       < %s | FileCheck %s -check-prefix=ALL -check-prefix=FULLREPORT
 # RUN: llvm-mca -mtriple=x86_64-unknown-unknown -mcpu=btver2 -resource-pressure=false -all-views < %s | FileCheck %s -check-prefix=ALL -check-prefix=FULLREPORT
-# RUN: llvm-mca -mtriple=x86_64-unknown-unknown -mcpu=btver2 -all-views -resource-pressure=false < %s | FileCheck %s -check-prefix=ALL -check-prefix=NORPV
+# RUN: llvm-mca -mtriple=x86_64-unknown-unknown -mcpu=btver2 -all-views -resource-pressure=false < %s | FileCheck %s -check-prefix=ALL
 
 add %eax, %eax
 
index 858da0e..e605ea9 100644 (file)
@@ -1,37 +1,37 @@
 # NOTE: Assertions have been autogenerated by utils/update_mca_test_checks.py
 # RUN: llvm-mca %s -mtriple=x86_64-unknown-unknown -mcpu=btver2 -iterations=1 -all-stats=false -all-views=false -register-file-stats < %s | FileCheck --check-prefixes=ALL,BTVER2 %s
 # RUN: llvm-mca %s -mtriple=x86_64-unknown-unknown -mcpu=znver1 -iterations=1 -all-stats=false -all-views=false -register-file-stats < %s | FileCheck --check-prefixes=ALL,ZNVER1 %s
-# RUN: llvm-mca %s -mtriple=x86_64-unknown-unknown -mcpu=sandybridge -iterations=1 -all-stats=false -all-views=false -register-file-stats < %s | FileCheck --check-prefixes=ALL,SNB %s
-# RUN: llvm-mca %s -mtriple=x86_64-unknown-unknown -mcpu=ivybridge -iterations=1 -all-stats=false -all-views=false -register-file-stats < %s | FileCheck --check-prefixes=ALL,IVB %s
-# RUN: llvm-mca %s -mtriple=x86_64-unknown-unknown -mcpu=haswell -iterations=1 -all-stats=false -all-views=false -register-file-stats < %s | FileCheck --check-prefixes=ALL,HSW %s
-# RUN: llvm-mca %s -mtriple=x86_64-unknown-unknown -mcpu=broadwell -iterations=1 -all-stats=false -all-views=false -register-file-stats < %s | FileCheck --check-prefixes=ALL,BDW %s
-# RUN: llvm-mca %s -mtriple=x86_64-unknown-unknown -mcpu=knl -iterations=1 -all-stats=false -all-views=false -register-file-stats < %s | FileCheck --check-prefixes=ALL,KNL %s
-# RUN: llvm-mca %s -mtriple=x86_64-unknown-unknown -mcpu=skylake -iterations=1 -all-stats=false -all-views=false -register-file-stats < %s | FileCheck --check-prefixes=ALL,SKX %s
-# RUN: llvm-mca %s -mtriple=x86_64-unknown-unknown -mcpu=skylake-avx512 -iterations=1 -all-stats=false -all-views=false -register-file-stats < %s | FileCheck --check-prefixes=ALL,SKX-AVX512 %s
-# RUN: llvm-mca %s -mtriple=x86_64-unknown-unknown -mcpu=slm -iterations=1 -all-stats=false -all-views=false -register-file-stats < %s | FileCheck --check-prefixes=ALL,SLM %s
+# RUN: llvm-mca %s -mtriple=x86_64-unknown-unknown -mcpu=sandybridge -iterations=1 -all-stats=false -all-views=false -register-file-stats < %s | FileCheck --check-prefixes=ALL %s
+# RUN: llvm-mca %s -mtriple=x86_64-unknown-unknown -mcpu=ivybridge -iterations=1 -all-stats=false -all-views=false -register-file-stats < %s | FileCheck --check-prefixes=ALL %s
+# RUN: llvm-mca %s -mtriple=x86_64-unknown-unknown -mcpu=haswell -iterations=1 -all-stats=false -all-views=false -register-file-stats < %s | FileCheck --check-prefixes=ALL %s
+# RUN: llvm-mca %s -mtriple=x86_64-unknown-unknown -mcpu=broadwell -iterations=1 -all-stats=false -all-views=false -register-file-stats < %s | FileCheck --check-prefixes=ALL %s
+# RUN: llvm-mca %s -mtriple=x86_64-unknown-unknown -mcpu=knl -iterations=1 -all-stats=false -all-views=false -register-file-stats < %s | FileCheck --check-prefixes=ALL %s
+# RUN: llvm-mca %s -mtriple=x86_64-unknown-unknown -mcpu=skylake -iterations=1 -all-stats=false -all-views=false -register-file-stats < %s | FileCheck --check-prefixes=ALL %s
+# RUN: llvm-mca %s -mtriple=x86_64-unknown-unknown -mcpu=skylake-avx512 -iterations=1 -all-stats=false -all-views=false -register-file-stats < %s | FileCheck --check-prefixes=ALL %s
+# RUN: llvm-mca %s -mtriple=x86_64-unknown-unknown -mcpu=slm -iterations=1 -all-stats=false -all-views=false -register-file-stats < %s | FileCheck --check-prefixes=ALL %s
 
 xor %eax, %ebx
 
-# ALL:             Register File statistics:
-# ALL-NEXT:        Total number of mappings created:    2
-# ALL-NEXT:        Max number of mappings used:         2
+# ALL:         Register File statistics:
+# ALL-NEXT:    Total number of mappings created:    2
+# ALL-NEXT:    Max number of mappings used:         2
 
-# BTVER2:          *  Register File #1 -- JFpuPRF:
-# BTVER2-NEXT:        Number of physical registers:     72
-# BTVER2-NEXT:        Total number of mappings created: 0
-# BTVER2-NEXT:        Max number of mappings used:      0
+# BTVER2:      *  Register File #1 -- JFpuPRF:
+# BTVER2-NEXT:    Number of physical registers:     72
+# BTVER2-NEXT:    Total number of mappings created: 0
+# BTVER2-NEXT:    Max number of mappings used:      0
 
-# ZNVER1:          *  Register File #1 -- ZnFpuPRF:
-# ZNVER1-NEXT:        Number of physical registers:     160
-# ZNVER1-NEXT:        Total number of mappings created: 0
-# ZNVER1-NEXT:        Max number of mappings used:      0
+# ZNVER1:      *  Register File #1 -- ZnFpuPRF:
+# ZNVER1-NEXT:    Number of physical registers:     160
+# ZNVER1-NEXT:    Total number of mappings created: 0
+# ZNVER1-NEXT:    Max number of mappings used:      0
 
-# BTVER2:          *  Register File #2 -- JIntegerPRF:
-# BTVER2-NEXT:        Number of physical registers:     64
-# BTVER2-NEXT:        Total number of mappings created: 2
-# BTVER2-NEXT:        Max number of mappings used:      2
+# BTVER2:      *  Register File #2 -- JIntegerPRF:
+# BTVER2-NEXT:    Number of physical registers:     64
+# BTVER2-NEXT:    Total number of mappings created: 2
+# BTVER2-NEXT:    Max number of mappings used:      2
 
-# ZNVER1:          *  Register File #2 -- ZnIntegerPRF:
-# ZNVER1-NEXT:        Number of physical registers:     168
-# ZNVER1-NEXT:        Total number of mappings created: 2
-# ZNVER1-NEXT:        Max number of mappings used:      2
+# ZNVER1:      *  Register File #2 -- ZnIntegerPRF:
+# ZNVER1-NEXT:    Number of physical registers:     168
+# ZNVER1-NEXT:    Total number of mappings created: 2
+# ZNVER1-NEXT:    Max number of mappings used:      2
index 88853bf..ae85b53 100755 (executable)
@@ -388,6 +388,9 @@ def _get_block_infos(run_infos, test_path, args, common_prefix):  # noqa
             _warn('Multiple prefixes generating same output: {} '
                   '(discarding {})'.format(','.join(s), ','.join(s[1:])))
 
+      if block_text and not current_set:
+        raise Error(
+          'block not captured by existing prefixes:\n\n{}'.format(block_text))
       block_infos[block_num][block_text] = sorted(list(current_set))
 
     # If we have multiple block_texts, try to break them down further to avoid
@@ -408,10 +411,12 @@ def _get_block_infos(run_infos, test_path, args, common_prefix):  # noqa
 
 def _write_block(output, block, not_prefix_set, common_prefix, prefix_pad):
   """ Write an individual block, with correct padding on the prefixes.
+      Returns a set of all of the prefixes that it has written.
   """
   end_prefix = ':     '
   previous_prefix = None
   num_lines_of_prefix = 0
+  written_prefixes = set()
 
   for prefix, line in block:
     if prefix in not_prefix_set:
@@ -431,6 +436,7 @@ def _write_block(output, block, not_prefix_set, common_prefix, prefix_pad):
       num_lines_of_prefix = 0
       previous_prefix = prefix
 
+    written_prefixes.add(prefix)
     output.append(
         '{} {}{}{} {}'.format(COMMENT_CHAR,
                               prefix,
@@ -440,6 +446,7 @@ def _write_block(output, block, not_prefix_set, common_prefix, prefix_pad):
     end_prefix = '-NEXT:'
 
   output.append('')
+  return written_prefixes
 
 
 def _write_output(test_path, input_lines, prefix_list, block_infos,  # noqa
@@ -483,6 +490,7 @@ def _write_output(test_path, input_lines, prefix_list, block_infos,  # noqa
     output_lines.append('')
 
   output_check_lines = []
+  used_prefixes = set()
   for block_num in range(len(block_infos)):
     for block_text in sorted(block_infos[block_num]):
       if not block_text:
@@ -490,22 +498,26 @@ def _write_output(test_path, input_lines, prefix_list, block_infos,  # noqa
 
       if type(block_infos[block_num]) is list:
         # The block is of the type output from _break_down_block().
-        _write_block(output_check_lines,
-                     block_infos[block_num],
-                     not_prefix_set,
-                     common_prefix,
-                     prefix_pad)
+        used_prefixes |= _write_block(output_check_lines,
+                                      block_infos[block_num],
+                                      not_prefix_set,
+                                      common_prefix,
+                                      prefix_pad)
         break
       elif block_infos[block_num][block_text]:
         # _break_down_block() was unable to do do anything so output the block
         # as-is.
         lines = block_text.split('\n')
         for prefix in block_infos[block_num][block_text]:
-          _write_block(output_check_lines,
-                       [(prefix, line) for line in lines],
-                       not_prefix_set,
-                       common_prefix,
-                       prefix_pad)
+          used_prefixes |= _write_block(output_check_lines,
+                                        [(prefix, line) for line in lines],
+                                        not_prefix_set,
+                                        common_prefix,
+                                        prefix_pad)
+
+  unused_prefixes = (prefix_set - not_prefix_set) - used_prefixes
+  if unused_prefixes:
+    raise Error('unused prefixes: {}'.format(sorted(unused_prefixes)))
 
   if output_check_lines:
     output_lines.insert(0, ADVERT)