Skip to content

Commit c5dd3c8

Browse files
wlei-llvmfacebook-github-bot
authored andcommitted
Fix pytorch JIT build for LLVM 18+ (pytorch#130661)
Summary: Pull Request resolved: pytorch#130661 LLVM upstream(llvm/llvm-project#97824) changed `getHostCPUFeatures`to use Return StringMap. Fix this to unblock T195389358 Test Plan: ``` buck2 build mode/opt-clang-thinlto --upload-all-actions -c unicorn.hfsort="1" -c cxx.extra_cxxflags="-gpubnames -w -Wno-enum-constexpr-conversion -Wno-missing-template-arg-list-after-template-kw -Wno-c++11-narrowing -Wno-c++11-narrowing-const-reference -ferror-limit=0" -c cxx.extra_cflags="-gpubnames -w -Wno-enum-constexpr-conversion -Wno-missing-template-arg-list-after-template-kw -Wno-c++11-narrowing -Wno-c++11-narrowing-const-reference" -c cxx.profile="fbcode//fdo/autofdo/unicorn/topaggr/top_aggregator_server:autofdo" unicorn/topaggr:top_aggregator_server ``` Reviewed By: WenleiHe Differential Revision: D59708722
1 parent 95dbbf7 commit c5dd3c8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

torch/csrc/jit/tensorexpr/llvm_jit.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,12 @@ static llvm::JITTargetAddress toAddress(T* Ptr) {
5656
// Get subtarget features for the host.
5757
static llvm::SubtargetFeatures getHostSubtargetFeatures() {
5858
llvm::SubtargetFeatures subtargetFeatures;
59+
#if LLVM_VERSION_MAJOR >= 18
60+
const auto featureMap = llvm::sys::getHostCPUFeatures();
61+
#else
5962
llvm::StringMap<bool> featureMap;
6063
llvm::sys::getHostCPUFeatures(featureMap);
64+
#endif
6165
for (auto& feature : featureMap) {
6266
subtargetFeatures.AddFeature(feature.first(), feature.second);
6367
}

0 commit comments

Comments
 (0)