[PATCH] D65760: [ORC] Add host CPU name and sub-target features to JITTargetMachineBuilder::detectHost()
Diego Caballero via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 5 11:04:08 PDT 2019
dcaballe created this revision.
dcaballe added reviewers: lhames, mehdi_amini.
Herald added subscribers: llvm-commits, rogfer01.
Herald added a project: LLVM.
We use `JITTargetMachineBuilder::detectHost()` in MLIR to create a target machine for the host CPU and noticed that the returned `JITTargetMachineBuilder` is not properly initialized with the host CPU name and sub-target features. This patch adds that information to the `JITTargetMachineBuilder` created in `JITTargetMachineBuilder::detectHost()`.
Please, let me know if there is a simple way to add a test for this.
Thanks!
Diego
Repository:
rL LLVM
https://reviews.llvm.org/D65760
Files:
lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp
Index: lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp
===================================================================
--- lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp
+++ lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp
@@ -22,7 +22,21 @@
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>>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65760.213405.patch
Type: text/x-patch
Size: 1204 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190805/ebd6b65d/attachment.bin>
More information about the llvm-commits
mailing list