diff options
author | David Spickett <david.spickett@linaro.org> | 2024-07-11 10:32:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-11 10:32:43 +0100 |
commit | 18e70a4d5042299054dae7d3995f6ccd8f4112b3 (patch) | |
tree | 5c4dc9a009623807360694f5ffaa1137ef967bed /llvm/lib/CodeGen/CommandFlags.cpp | |
parent | 55c00485eb05dfa75d4a20efff2131edd111066d (diff) | |
download | llvm-18e70a4d5042299054dae7d3995f6ccd8f4112b3.zip llvm-18e70a4d5042299054dae7d3995f6ccd8f4112b3.tar.gz llvm-18e70a4d5042299054dae7d3995f6ccd8f4112b3.tar.bz2 |
[llvm][TargetParser] Return StringMap from getHostCPUFeatures (#97824)
Previously this took a reference to a map and returned a bool to say
whether it succeeded. We can return a StringMap instead, as all callers
but 1 simply iterated the map if the bool was true, and passed in empty
maps as the starting point.
lldb's lit-cpuid did specifically check whether the call failed, but due
to the way the x86 routines work this works out the same as checking if
the returned map is empty.
Diffstat (limited to 'llvm/lib/CodeGen/CommandFlags.cpp')
-rw-r--r-- | llvm/lib/CodeGen/CommandFlags.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/llvm/lib/CodeGen/CommandFlags.cpp b/llvm/lib/CodeGen/CommandFlags.cpp index 8fc65d7..9e42deb 100644 --- a/llvm/lib/CodeGen/CommandFlags.cpp +++ b/llvm/lib/CodeGen/CommandFlags.cpp @@ -624,12 +624,9 @@ std::string codegen::getFeaturesStr() { // 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 (getMCPU() == "native") { - StringMap<bool> HostFeatures; - if (sys::getHostCPUFeatures(HostFeatures)) - for (const auto &[Feature, IsEnabled] : HostFeatures) - Features.AddFeature(Feature, IsEnabled); - } + if (getMCPU() == "native") + for (const auto &[Feature, IsEnabled] : sys::getHostCPUFeatures()) + Features.AddFeature(Feature, IsEnabled); for (auto const &MAttr : getMAttrs()) Features.AddFeature(MAttr); @@ -644,12 +641,9 @@ std::vector<std::string> codegen::getFeatureList() { // 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 (getMCPU() == "native") { - StringMap<bool> HostFeatures; - if (sys::getHostCPUFeatures(HostFeatures)) - for (const auto &[Feature, IsEnabled] : HostFeatures) - Features.AddFeature(Feature, IsEnabled); - } + if (getMCPU() == "native") + for (const auto &[Feature, IsEnabled] : sys::getHostCPUFeatures()) + Features.AddFeature(Feature, IsEnabled); for (auto const &MAttr : getMAttrs()) Features.AddFeature(MAttr); |