Skip to content

Commit df33d73

Browse files
[LLVM] Fix for getHostCPUFeatures API change (#17199)
This patch fixes a minor API change in latest LLVM.
1 parent 1b6c00d commit df33d73

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/target/llvm/codegen_llvm.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2315,6 +2315,16 @@ TVM_REGISTER_GLOBAL("tvm.codegen.llvm.GetHostCPUName").set_body_typed([]() -> st
23152315

23162316
TVM_REGISTER_GLOBAL("tvm.codegen.llvm.GetHostCPUFeatures")
23172317
.set_body_typed([]() -> Map<String, IntImm> {
2318+
#if TVM_LLVM_VERSION >= 200
2319+
Map<String, IntImm> ret;
2320+
auto features = llvm::sys::getHostCPUFeatures();
2321+
for (auto it = features.begin(); it != features.end(); ++it) {
2322+
std::string name = it->getKey().str();
2323+
bool value = it->getValue();
2324+
ret.Set(name, IntImm(DataType::Bool(), value));
2325+
}
2326+
return ret;
2327+
#else
23182328
llvm::StringMap<bool> features;
23192329
if (llvm::sys::getHostCPUFeatures(features)) {
23202330
Map<String, IntImm> ret;
@@ -2325,6 +2335,7 @@ TVM_REGISTER_GLOBAL("tvm.codegen.llvm.GetHostCPUFeatures")
23252335
}
23262336
return ret;
23272337
}
2338+
#endif
23282339
LOG(WARNING) << "Current version of LLVM does not support feature detection on your CPU";
23292340
return {};
23302341
});

0 commit comments

Comments
 (0)