]> granicus.if.org Git - llvm/commitdiff
Re-land D65760/r367944
authorDiego Caballero <diego.caballero@intel.com>
Tue, 6 Aug 2019 16:24:17 +0000 (16:24 +0000)
committerDiego Caballero <diego.caballero@intel.com>
Tue, 6 Aug 2019 16:24:17 +0000 (16:24 +0000)
Fixed most vexing parse ambiguation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368055 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp

index df23547a9de3ab0345ac57f2de2ba9d9c3e85dbb..359ef99472abcbf9415c555cd2ed1c8a9f6b29e1 100644 (file)
@@ -22,7 +22,21 @@ JITTargetMachineBuilder::JITTargetMachineBuilder(Triple TT)
 Expected<JITTargetMachineBuilder> JITTargetMachineBuilder::detectHost() {
   // FIXME: getProcessTriple is bogus. It returns the host LLVM was compiled on,
   //        rather than a valid triple for the current process.
-  return JITTargetMachineBuilder(Triple(sys::getProcessTriple()));
+  JITTargetMachineBuilder TMBuilder((Triple(sys::getProcessTriple())));
+
+  // Retrieve host CPU name and sub-target features and add them to builder.
+  // Relocation model, code model and codegen opt level are kept to default
+  // values.
+  llvm::SubtargetFeatures SubtargetFeatures;
+  llvm::StringMap<bool> FeatureMap;
+  llvm::sys::getHostCPUFeatures(FeatureMap);
+  for (auto &Feature : FeatureMap)
+    SubtargetFeatures.AddFeature(Feature.first(), Feature.second);
+
+  TMBuilder.setCPU(llvm::sys::getHostCPUName());
+  TMBuilder.addFeatures(SubtargetFeatures.getFeatures());
+
+  return TMBuilder;
 }
 
 Expected<std::unique_ptr<TargetMachine>>