Skip to content

Commit

Permalink
Fix pytorch JIT build for LLVM 18+ (pytorch#130661)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
wlei-llvm authored and facebook-github-bot committed Jul 16, 2024
1 parent 0851de5 commit af02a04
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions torch/csrc/jit/tensorexpr/llvm_jit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ static llvm::JITTargetAddress toAddress(T* Ptr) {
// Get subtarget features for the host.
static llvm::SubtargetFeatures getHostSubtargetFeatures() {
llvm::SubtargetFeatures subtargetFeatures;
#if LLVM_VERSION_MAJOR >= 18
const auto featureMap = llvm::sys::getHostCPUFeatures();
#else
llvm::StringMap<bool> featureMap;
llvm::sys::getHostCPUFeatures(featureMap);
#endif
for (auto& feature : featureMap) {
subtargetFeatures.AddFeature(feature.first(), feature.second);
}
Expand Down

0 comments on commit af02a04

Please sign in to comment.