Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[llvm][TargetParser] Return StringMap from getHostCPUFeatures #97824

Merged
merged 9 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
const return type
  • Loading branch information
DavidSpickett committed Jul 10, 2024
commit 6a6b38b94932cb677a09eefe005e4fe11e47fea9
2 changes: 1 addition & 1 deletion llvm/include/llvm/TargetParser/Host.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace sys {
/// which features may appear in this map, except that they are all valid LLVM
/// feature names. The map can be empty, for example if feature detection
/// fails.
StringMap<bool, MallocAllocator> getHostCPUFeatures();
const StringMap<bool, MallocAllocator> getHostCPUFeatures();

/// This is a function compatible with cl::AddExtraVersionPrinter, which adds
/// info about the current target triple and detected CPU.
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Expected<JITTargetMachineBuilder> JITTargetMachineBuilder::detectHost() {
// 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.
for (auto &Feature : llvm::sys::getHostCPUFeatures())
for (const auto &Feature : llvm::sys::getHostCPUFeatures())
TMBuilder.getFeatures().AddFeature(Feature.first(), Feature.second);

TMBuilder.setCPU(std::string(llvm::sys::getHostCPUName()));
Expand Down
10 changes: 5 additions & 5 deletions llvm/lib/TargetParser/Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1710,7 +1710,7 @@ VendorSignatures getVendorSignature(unsigned *MaxLeaf) {

#if defined(__i386__) || defined(_M_IX86) || \
defined(__x86_64__) || defined(_M_X64)
StringMap<bool> sys::getHostCPUFeatures() {
const StringMap<bool> sys::getHostCPUFeatures() {
unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0;
unsigned MaxLevel;
StringMap<bool> Features;
Expand Down Expand Up @@ -1907,7 +1907,7 @@ StringMap<bool> sys::getHostCPUFeatures() {
return Features;
}
#elif defined(__linux__) && (defined(__arm__) || defined(__aarch64__))
StringMap<bool> sys::getHostCPUFeatures() {
const StringMap<bool> sys::getHostCPUFeatures() {
StringMap<bool> Features;
std::unique_ptr<llvm::MemoryBuffer> P = getProcCpuinfoContent();
if (!P)
Expand Down Expand Up @@ -1977,7 +1977,7 @@ StringMap<bool> sys::getHostCPUFeatures() {
return Features;
}
#elif defined(_WIN32) && (defined(__aarch64__) || defined(_M_ARM64))
StringMap<bool> sys::getHostCPUFeatures() {
const StringMap<bool> sys::getHostCPUFeatures() {
StringMap<bool> Features;

if (IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE))
Expand All @@ -1991,7 +1991,7 @@ StringMap<bool> sys::getHostCPUFeatures() {
}
#elif defined(__linux__) && defined(__loongarch__)
#include <sys/auxv.h>
StringMap<bool> sys::getHostCPUFeatures() {
const StringMap<bool> sys::getHostCPUFeatures() {
unsigned long hwcap = getauxval(AT_HWCAP);
bool HasFPU = hwcap & (1UL << 3); // HWCAP_LOONGARCH_FPU
uint32_t cpucfg2 = 0x2;
Expand All @@ -2009,7 +2009,7 @@ StringMap<bool> sys::getHostCPUFeatures() {
return Features;
}
#else
StringMap<bool> sys::getHostCPUFeatures() { return {}; }
const StringMap<bool> sys::getHostCPUFeatures() { return {}; }
#endif

#if __APPLE__
Expand Down
Loading