Skip to content

Commit

Permalink
[mlir][SystemZ] Fix incompatible datalayout in SystemZ
Browse files Browse the repository at this point in the history
MLIR tests in "mlir/test/mlir-cpu-runner" fails in SystemZ (z14) because
of incompatible datalayout error. This patch fixes it by setting host
CPU name in createTargetMachine()

Differential Revision: https://reviews.llvm.org/D80130
  • Loading branch information
imaihal authored and joker-eph committed May 20, 2020
1 parent 8d0fdd4 commit 9f2ce5b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions mlir/lib/ExecutionEngine/ExecutionEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/MC/SubtargetFeature.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/Host.h"
Expand Down Expand Up @@ -119,8 +120,17 @@ bool ExecutionEngine::setupTargetTriple(Module *llvmModule) {
errs() << "NO target: " << errorMessage << "\n";
return true;
}
std::unique_ptr<llvm::TargetMachine> machine(
target->createTargetMachine(targetTriple, "generic", "", {}, {}));

std::string cpu(llvm::sys::getHostCPUName());
llvm::SubtargetFeatures features;
llvm::StringMap<bool> hostFeatures;

if (llvm::sys::getHostCPUFeatures(hostFeatures))
for (auto &f : hostFeatures)
features.AddFeature(f.first(), f.second);

std::unique_ptr<llvm::TargetMachine> machine(target->createTargetMachine(
targetTriple, cpu, features.getString(), {}, {}));
llvmModule->setDataLayout(machine->createDataLayout());
llvmModule->setTargetTriple(targetTriple);
return false;
Expand Down

0 comments on commit 9f2ce5b

Please sign in to comment.