diff options
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/CodeGen/CommandFlags.def | 20 | ||||
| -rw-r--r-- | llvm/tools/lli/lli.cpp | 4 |
2 files changed, 22 insertions, 2 deletions
diff --git a/llvm/include/llvm/CodeGen/CommandFlags.def b/llvm/include/llvm/CodeGen/CommandFlags.def index fe96033a9c6..d7a5c946ad5 100644 --- a/llvm/include/llvm/CodeGen/CommandFlags.def +++ b/llvm/include/llvm/CodeGen/CommandFlags.def @@ -326,6 +326,26 @@ LLVM_ATTRIBUTE_UNUSED static std::string getFeaturesStr() { return Features.getString(); } +LLVM_ATTRIBUTE_UNUSED static std::vector<std::string> getFeatureList() { + SubtargetFeatures Features; + + // If user asked for the 'native' CPU, we need to autodetect features. + // This is necessary for x86 where the CPU might not support all the + // features the autodetected CPU name lists in the target. For example, + // not all Sandybridge processors support AVX. + if (MCPU == "native") { + StringMap<bool> HostFeatures; + if (sys::getHostCPUFeatures(HostFeatures)) + for (auto &F : HostFeatures) + Features.AddFeature(F.first(), F.second); + } + + for (unsigned i = 0; i != MAttrs.size(); ++i) + Features.AddFeature(MAttrs[i]); + + return Features.getFeatures(); +} + /// \brief Set function attributes of functions in Module M based on CPU, /// Features, and command line flags. LLVM_ATTRIBUTE_UNUSED static void diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp index a33c51d7787..ede5ea751d6 100644 --- a/llvm/tools/lli/lli.cpp +++ b/llvm/tools/lli/lli.cpp @@ -378,8 +378,8 @@ int main(int argc, char **argv, char * const *envp) { std::string ErrorMsg; EngineBuilder builder(std::move(Owner)); builder.setMArch(MArch); - builder.setMCPU(MCPU); - builder.setMAttrs(MAttrs); + builder.setMCPU(getCPUStr()); + builder.setMAttrs(getFeatureList()); if (RelocModel.getNumOccurrences()) builder.setRelocationModel(RelocModel); if (CMModel.getNumOccurrences()) |

