[llvm] r330809 - [llvm-mca] Default to the native host cpu if flag -mcpu is not specified.

Andrea Di Biagio via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 25 03:18:25 PDT 2018


Author: adibiagio
Date: Wed Apr 25 03:18:25 2018
New Revision: 330809

URL: http://llvm.org/viewvc/llvm-project?rev=330809&view=rev
Log:
[llvm-mca] Default to the native host cpu if flag -mcpu is not specified.

Modified:
    llvm/trunk/docs/CommandGuide/llvm-mca.rst
    llvm/trunk/test/tools/llvm-mca/X86/no-sched-model.s
    llvm/trunk/tools/llvm-mca/llvm-mca.cpp

Modified: llvm/trunk/docs/CommandGuide/llvm-mca.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/llvm-mca.rst?rev=330809&r1=330808&r2=330809&view=diff
==============================================================================
--- llvm/trunk/docs/CommandGuide/llvm-mca.rst (original)
+++ llvm/trunk/docs/CommandGuide/llvm-mca.rst Wed Apr 25 03:18:25 2018
@@ -89,9 +89,8 @@ option specifies "``-``", then the outpu
 
 .. option:: -mcpu=<cpuname>
 
- Specify the processor for whic to run the analysis.
- By default this defaults to a "generic" processor. It is not autodetected to
- the current architecture.
+  Specify the processor for which to analyze the code.  By default, the cpu name
+  is autodetected from the host.
 
 .. option:: -output-asm-variant=<variant id>
 

Modified: llvm/trunk/test/tools/llvm-mca/X86/no-sched-model.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-mca/X86/no-sched-model.s?rev=330809&r1=330808&r2=330809&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-mca/X86/no-sched-model.s (original)
+++ llvm/trunk/test/tools/llvm-mca/X86/no-sched-model.s Wed Apr 25 03:18:25 2018
@@ -1,4 +1,3 @@
-# RUN: not llvm-mca -mtriple=x86_64-unknown-unknown < %s 2>&1 | FileCheck %s
 # RUN: not llvm-mca -mtriple=x86_64-unknown-unknown -mcpu=generic < %s 2>&1 | FileCheck %s
 
 # CHECK: error: unable to find instruction-level scheduling information for target triple 'x86_64-unknown-unknown' and cpu 'generic'.

Modified: llvm/trunk/tools/llvm-mca/llvm-mca.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/llvm-mca.cpp?rev=330809&r1=330808&r2=330809&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/llvm-mca.cpp (original)
+++ llvm/trunk/tools/llvm-mca/llvm-mca.cpp Wed Apr 25 03:18:25 2018
@@ -16,7 +16,7 @@
 //      -o <file>
 //
 // The target defaults to the host target.
-// The cpu defaults to 'generic'.
+// The cpu defaults to the 'native' host cpu.
 // The output defaults to standard output.
 //
 //===----------------------------------------------------------------------===//
@@ -38,6 +38,7 @@
 #include "llvm/MC/MCParser/MCTargetAsmParser.h"
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCStreamer.h"
+#include "llvm/Support/Host.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
@@ -69,7 +70,7 @@ static cl::opt<std::string>
 static cl::opt<std::string>
     MCPU("mcpu",
          cl::desc("Target a specific cpu type (-mcpu=help for details)"),
-         cl::value_desc("cpu-name"), cl::init("generic"));
+         cl::value_desc("cpu-name"), cl::init("native"));
 
 static cl::opt<int>
     OutputAsmVariant("output-asm-variant",
@@ -329,6 +330,10 @@ int main(int argc, char **argv) {
   MCStreamerWrapper Str(Ctx, Regions);
 
   std::unique_ptr<MCInstrInfo> MCII(TheTarget->createMCInstrInfo());
+
+  if (!MCPU.compare("native"))
+    MCPU = llvm::sys::getHostCPUName();
+
   std::unique_ptr<MCSubtargetInfo> STI(
       TheTarget->createMCSubtargetInfo(TripleName, MCPU, /* FeaturesStr */ ""));
   if (!STI->isCPUStringValid(MCPU))




More information about the llvm-commits mailing list