From: Diego Caballero Date: Tue, 6 Aug 2019 16:24:17 +0000 (+0000) Subject: Re-land D65760/r367944 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0b472ff2ae4364802f0bd6260680b7672c464473;p=llvm Re-land D65760/r367944 Fixed most vexing parse ambiguation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368055 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp b/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp index df23547a9de..359ef99472a 100644 --- a/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp +++ b/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp @@ -22,7 +22,21 @@ JITTargetMachineBuilder::JITTargetMachineBuilder(Triple TT) Expected 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 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>