[Mlir-commits] [mlir] 9f2ce5b - [mlir][SystemZ] Fix incompatible datalayout in SystemZ

Mehdi Amini llvmlistbot at llvm.org
Tue May 19 20:46:39 PDT 2020


Author: Haruki Imai
Date: 2020-05-20T03:46:26Z
New Revision: 9f2ce5b915a505a5488a5cf91bb0a8efa9ddfff7

URL: https://github.com/llvm/llvm-project/commit/9f2ce5b915a505a5488a5cf91bb0a8efa9ddfff7
DIFF: https://github.com/llvm/llvm-project/commit/9f2ce5b915a505a5488a5cf91bb0a8efa9ddfff7.diff

LOG: [mlir][SystemZ] Fix incompatible datalayout in SystemZ

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

Added: 
    

Modified: 
    mlir/lib/ExecutionEngine/ExecutionEngine.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp
index fe896df65719..c64c7d208dec 100644
--- a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -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"
@@ -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;


        


More information about the Mlir-commits mailing list