[llvm] r342975 - [llvm-exegesis] Add lit tests (v2).

Clement Courbet via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 25 06:59:35 PDT 2018


Author: courbet
Date: Tue Sep 25 06:59:35 2018
New Revision: 342975

URL: http://llvm.org/viewvc/llvm-project?rev=342975&view=rev
Log:
[llvm-exegesis] Add lit tests (v2).

Summary: This revisits rL342953 by adding detection of host support.

Reviewers: gchatelet, lebedev.ri, alexshap

Subscribers: mgorny, tschuett, llvm-commits

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

Added:
    llvm/trunk/test/tools/llvm-exegesis/X86/latency-by-opcode-name.s
    llvm/trunk/test/tools/llvm-exegesis/X86/lit.local.cfg
    llvm/trunk/test/tools/llvm-exegesis/X86/uops-by-opcode-name.s
    llvm/trunk/test/tools/llvm-exegesis/lit.local.cfg
Modified:
    llvm/trunk/test/CMakeLists.txt
    llvm/trunk/test/lit.cfg.py
    llvm/trunk/tools/llvm-exegesis/lib/BenchmarkRunner.cpp

Modified: llvm/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CMakeLists.txt?rev=342975&r1=342974&r2=342975&view=diff
==============================================================================
--- llvm/trunk/test/CMakeLists.txt (original)
+++ llvm/trunk/test/CMakeLists.txt Tue Sep 25 06:59:35 2018
@@ -60,6 +60,7 @@ set(LLVM_TEST_DEPENDS
           dsymutil
           llvm-dwarfdump
           llvm-dwp
+          llvm-exegesis
           llvm-extract
           llvm-isel-fuzzer
           llvm-lib

Modified: llvm/trunk/test/lit.cfg.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/lit.cfg.py?rev=342975&r1=342974&r2=342975&view=diff
==============================================================================
--- llvm/trunk/test/lit.cfg.py (original)
+++ llvm/trunk/test/lit.cfg.py Tue Sep 25 06:59:35 2018
@@ -140,16 +140,17 @@ tools = [
 
 # FIXME: Why do we have both `lli` and `%lli` that do slightly different things?
 tools.extend([
-    'dsymutil', 'lli', 'lli-child-target', 'llvm-ar', 'llvm-as', 'llvm-bcanalyzer',
-    'llvm-config', 'llvm-cov', 'llvm-cxxdump', 'llvm-cvtres', 'llvm-diff', 'llvm-dis',
-    'llvm-dwarfdump', 'llvm-extract', 'llvm-isel-fuzzer', 'llvm-opt-fuzzer', 'llvm-lib',
-    'llvm-link', 'llvm-lto', 'llvm-lto2', 'llvm-mc', 'llvm-mca',
-    'llvm-modextract', 'llvm-nm', 'llvm-objcopy', 'llvm-objdump',
-    'llvm-pdbutil', 'llvm-profdata', 'llvm-ranlib', 'llvm-readobj',
-    'llvm-rtdyld', 'llvm-size', 'llvm-split', 'llvm-strings', 'llvm-strip', 'llvm-tblgen',
-    'llvm-undname', 'llvm-c-test', 'llvm-cxxfilt', 'llvm-xray', 'yaml2obj', 'obj2yaml',
-    'yaml-bench', 'verify-uselistorder',
-    'bugpoint', 'llc', 'llvm-symbolizer', 'opt', 'sancov', 'sanstats'])
+    'dsymutil', 'lli', 'lli-child-target', 'llvm-ar', 'llvm-as',
+    'llvm-bcanalyzer', 'llvm-config', 'llvm-cov', 'llvm-cxxdump', 'llvm-cvtres',
+    'llvm-diff', 'llvm-dis', 'llvm-dwarfdump', 'llvm-exegesis', 'llvm-extract',
+    'llvm-isel-fuzzer', 'llvm-opt-fuzzer', 'llvm-lib', 'llvm-link', 'llvm-lto',
+    'llvm-lto2', 'llvm-mc', 'llvm-mca', 'llvm-modextract', 'llvm-nm',
+    'llvm-objcopy', 'llvm-objdump', 'llvm-pdbutil', 'llvm-profdata',
+    'llvm-ranlib', 'llvm-readobj', 'llvm-rtdyld', 'llvm-size', 'llvm-split',
+    'llvm-strings', 'llvm-strip', 'llvm-tblgen', 'llvm-undname', 'llvm-c-test',
+    'llvm-cxxfilt', 'llvm-xray', 'yaml2obj', 'obj2yaml', 'yaml-bench',
+    'verify-uselistorder', 'bugpoint', 'llc', 'llvm-symbolizer', 'opt',
+    'sancov', 'sanstats'])
 
 # The following tools are optional
 tools.extend([

Added: llvm/trunk/test/tools/llvm-exegesis/X86/latency-by-opcode-name.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-exegesis/X86/latency-by-opcode-name.s?rev=342975&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-exegesis/X86/latency-by-opcode-name.s (added)
+++ llvm/trunk/test/tools/llvm-exegesis/X86/latency-by-opcode-name.s Tue Sep 25 06:59:35 2018
@@ -0,0 +1,6 @@
+# RUN: llvm-exegesis -mode=latency -opcode-name=ADD32rr | FileCheck %s
+
+CHECK:      mode:            latency
+CHECK-NEXT: key:
+CHECK-NEXT:   instructions:
+CHECK-NEXT:     ADD32rr

Added: llvm/trunk/test/tools/llvm-exegesis/X86/lit.local.cfg
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-exegesis/X86/lit.local.cfg?rev=342975&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-exegesis/X86/lit.local.cfg (added)
+++ llvm/trunk/test/tools/llvm-exegesis/X86/lit.local.cfg Tue Sep 25 06:59:35 2018
@@ -0,0 +1,29 @@
+import subprocess
+import lit.util
+
+if not ('X86' in config.root.targets):
+    # We need support for X86.
+    config.unsupported = True
+
+elif not ('x86_64' in config.root.host_triple):
+    # We need to be running on an X86 host.
+    config.unsupported = True
+
+else:
+    # We need libpfm to be installed and allow reading perf counters. We can
+    # only know that at runtime, so we try to measure the latency of an empty
+    # code snippet and bail out on error.
+    llvm_exegesis_exe = lit.util.which('llvm-exegesis', config.llvm_tools_dir)
+    if not llvm_exegesis_exe:
+        print('llvm-exegesis not found')
+        config.unsupported = True
+    else:
+      try:
+          with open(os.devnull, 'w') as quiet:
+              check_llvm_exegesis_result = subprocess.call(
+                [llvm_exegesis_exe, '-mode', 'uops', '-snippets-file', '/dev/null'], stdout=quiet)
+      except OSError:
+          print('could not exec llvm-exegesis')
+          config.unsupported = True
+      if not check_llvm_exegesis_result == 0:
+        config.unsupported = True

Added: llvm/trunk/test/tools/llvm-exegesis/X86/uops-by-opcode-name.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-exegesis/X86/uops-by-opcode-name.s?rev=342975&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-exegesis/X86/uops-by-opcode-name.s (added)
+++ llvm/trunk/test/tools/llvm-exegesis/X86/uops-by-opcode-name.s Tue Sep 25 06:59:35 2018
@@ -0,0 +1,6 @@
+# RUN: llvm-exegesis -mode=uops -opcode-name=ADD32rr | FileCheck %s
+
+CHECK:      mode:            uops
+CHECK-NEXT: key:
+CHECK-NEXT:   instructions:
+CHECK-NEXT:     ADD32rr

Added: llvm/trunk/test/tools/llvm-exegesis/lit.local.cfg
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-exegesis/lit.local.cfg?rev=342975&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-exegesis/lit.local.cfg (added)
+++ llvm/trunk/test/tools/llvm-exegesis/lit.local.cfg Tue Sep 25 06:59:35 2018
@@ -0,0 +1,2 @@
+if 'native' not in config.available_features:
+    config.unsupported = True

Modified: llvm/trunk/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-exegesis/lib/BenchmarkRunner.cpp?rev=342975&r1=342974&r2=342975&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-exegesis/lib/BenchmarkRunner.cpp (original)
+++ llvm/trunk/tools/llvm-exegesis/lib/BenchmarkRunner.cpp Tue Sep 25 06:59:35 2018
@@ -35,6 +35,8 @@ BenchmarkRunner::~BenchmarkRunner() = de
 // code.
 static std::vector<llvm::MCInst>
 GenerateInstructions(const BenchmarkCode &BC, const size_t MinInstructions) {
+  if (BC.Instructions.empty())
+    return {};
   std::vector<llvm::MCInst> Code = BC.Instructions;
   for (int I = 0; Code.size() < MinInstructions; ++I)
     Code.push_back(BC.Instructions[I % BC.Instructions.size()]);
@@ -53,10 +55,6 @@ BenchmarkRunner::runConfiguration(const
   InstrBenchmark.Info = BC.Info;
 
   const std::vector<llvm::MCInst> &Instructions = BC.Instructions;
-  if (Instructions.empty()) {
-    InstrBenchmark.Error = "Empty snippet";
-    return InstrBenchmark;
-  }
 
   InstrBenchmark.Key.Instructions = Instructions;
 




More information about the llvm-commits mailing list