Skip to content

Commit 5a27a96

Browse files
[Exegesis] CPU selection, when native arch and target mismatch
1 parent dd181af commit 5a27a96

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

Diff for: llvm/tools/llvm-exegesis/lib/LlvmState.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ Expected<LLVMState> LLVMState::Create(std::string TripleName,
4545
if (CpuName == "native")
4646
CpuName = std::string(sys::getHostCPUName());
4747

48+
if (CpuName.empty()) {
49+
std::unique_ptr<MCSubtargetInfo> Empty_STI(
50+
TheTarget->createMCSubtargetInfo(TripleName, "", ""));
51+
CpuName = Empty_STI->getAllProcessorDescriptions().begin()->Key;
52+
}
53+
4854
std::unique_ptr<MCSubtargetInfo> STI(
4955
TheTarget->createMCSubtargetInfo(TripleName, CpuName, ""));
5056
assert(STI && "Unable to create subtarget info!");

Diff for: llvm/tools/llvm-exegesis/llvm-exegesis.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include "llvm/Support/SourceMgr.h"
4545
#include "llvm/Support/TargetSelect.h"
4646
#include "llvm/TargetParser/Host.h"
47+
#include "llvm/TargetParser/Triple.h"
4748
#include <algorithm>
4849
#include <string>
4950

@@ -479,6 +480,10 @@ void benchmarkMain() {
479480
#endif
480481
}
481482

483+
// case for cross generating, when native arch and target mismatch
484+
if ((Triple(sys::getProcessTriple()).getArch() != Triple(TripleName).getArch()) && (MCPU == "native"))
485+
MCPU = "";
486+
482487
InitializeAllExegesisTargets();
483488
#define LLVM_EXEGESIS(TargetName) \
484489
LLVMInitialize##TargetName##AsmPrinter(); \

0 commit comments

Comments
 (0)