Skip to content

Commit 8bac177

Browse files
committed
Re-land D65760/r367944
Fixed most vexing parse ambiguation. llvm-svn: 368055
1 parent 6c619aa commit 8bac177

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,21 @@ JITTargetMachineBuilder::JITTargetMachineBuilder(Triple TT)
2222
Expected<JITTargetMachineBuilder> JITTargetMachineBuilder::detectHost() {
2323
// FIXME: getProcessTriple is bogus. It returns the host LLVM was compiled on,
2424
// rather than a valid triple for the current process.
25-
return JITTargetMachineBuilder(Triple(sys::getProcessTriple()));
25+
JITTargetMachineBuilder TMBuilder((Triple(sys::getProcessTriple())));
26+
27+
// Retrieve host CPU name and sub-target features and add them to builder.
28+
// Relocation model, code model and codegen opt level are kept to default
29+
// values.
30+
llvm::SubtargetFeatures SubtargetFeatures;
31+
llvm::StringMap<bool> FeatureMap;
32+
llvm::sys::getHostCPUFeatures(FeatureMap);
33+
for (auto &Feature : FeatureMap)
34+
SubtargetFeatures.AddFeature(Feature.first(), Feature.second);
35+
36+
TMBuilder.setCPU(llvm::sys::getHostCPUName());
37+
TMBuilder.addFeatures(SubtargetFeatures.getFeatures());
38+
39+
return TMBuilder;
2640
}
2741

2842
Expected<std::unique_ptr<TargetMachine>>

0 commit comments

Comments
 (0)