From: Andrea Di Biagio Date: Wed, 25 Apr 2018 10:18:25 +0000 (+0000) Subject: [llvm-mca] Default to the native host cpu if flag -mcpu is not specified. X-Git-Tag: llvmorg-7.0.0-rc1~7434 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=93c49d5e58d25cde1a6b0acac8e2a322534c8c36;p=platform%2Fupstream%2Fllvm.git [llvm-mca] Default to the native host cpu if flag -mcpu is not specified. llvm-svn: 330809 --- diff --git a/llvm/docs/CommandGuide/llvm-mca.rst b/llvm/docs/CommandGuide/llvm-mca.rst index 54610d7..63f2e65 100644 --- a/llvm/docs/CommandGuide/llvm-mca.rst +++ b/llvm/docs/CommandGuide/llvm-mca.rst @@ -89,9 +89,8 @@ option specifies "``-``", then the output will also be sent to standard output. .. option:: -mcpu= - 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= diff --git a/llvm/test/tools/llvm-mca/X86/no-sched-model.s b/llvm/test/tools/llvm-mca/X86/no-sched-model.s index e65e3ce..c01c0fc 100644 --- a/llvm/test/tools/llvm-mca/X86/no-sched-model.s +++ b/llvm/test/tools/llvm-mca/X86/no-sched-model.s @@ -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'. diff --git a/llvm/tools/llvm-mca/llvm-mca.cpp b/llvm/tools/llvm-mca/llvm-mca.cpp index da0a362..0e1d18e 100644 --- a/llvm/tools/llvm-mca/llvm-mca.cpp +++ b/llvm/tools/llvm-mca/llvm-mca.cpp @@ -16,7 +16,7 @@ // -o // // 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 static cl::opt 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 OutputAsmVariant("output-asm-variant", @@ -329,6 +330,10 @@ int main(int argc, char **argv) { MCStreamerWrapper Str(Ctx, Regions); std::unique_ptr MCII(TheTarget->createMCInstrInfo()); + + if (!MCPU.compare("native")) + MCPU = llvm::sys::getHostCPUName(); + std::unique_ptr STI( TheTarget->createMCSubtargetInfo(TripleName, MCPU, /* FeaturesStr */ "")); if (!STI->isCPUStringValid(MCPU))