-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
[C++][Gandiva] Support LLVM 17 #37834
Comments
I tried this a bit: diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index f2906b960..f0acab038 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -152,6 +152,7 @@ set(ARROW_DOC_DIR "share/doc/${PROJECT_NAME}")
set(BUILD_SUPPORT_DIR "${CMAKE_SOURCE_DIR}/build-support")
set(ARROW_LLVM_VERSIONS
+ "17.0"
"16.0"
"15.0"
"14.0"
diff --git a/cpp/src/gandiva/CMakeLists.txt b/cpp/src/gandiva/CMakeLists.txt
index db260b5ac..d2810c39f 100644
--- a/cpp/src/gandiva/CMakeLists.txt
+++ b/cpp/src/gandiva/CMakeLists.txt
@@ -31,8 +31,6 @@ if(ARROW_WITH_ZSTD AND "${zstd_SOURCE}" STREQUAL "SYSTEM")
provide_find_module(zstdAlt "Gandiva")
endif()
-add_definitions(-DGANDIVA_LLVM_VERSION=${LLVM_VERSION_MAJOR})
-
# Set the path where the bitcode file generated, see precompiled/CMakeLists.txt
set(GANDIVA_PRECOMPILED_BC_PATH "${CMAKE_CURRENT_BINARY_DIR}/irhelpers.bc")
set(GANDIVA_PRECOMPILED_CC_PATH "${CMAKE_CURRENT_BINARY_DIR}/precompiled_bitcode.cc")
diff --git a/cpp/src/gandiva/engine.cc b/cpp/src/gandiva/engine.cc
index 7d75793a3..511f7cc11 100644
--- a/cpp/src/gandiva/engine.cc
+++ b/cpp/src/gandiva/engine.cc
@@ -53,7 +53,11 @@
#include <llvm/IR/LegacyPassManager.h>
#include <llvm/IR/Verifier.h>
#include <llvm/Linker/Linker.h>
+#if LLVM_VERSION_MAJOR >= 17
+#include <llvm/TargetParser/SubtargetFeature.h>
+#else
#include <llvm/MC/SubtargetFeature.h>
+#endif
#include <llvm/Support/DynamicLibrary.h>
#include <llvm/Support/Host.h>
#if LLVM_VERSION_MAJOR >= 14 But it seems that we need to migrate our code to the new pass manager: https://llvm.org/docs/NewPassManager.html |
@kou, I haven't delved into the new pass manager API, but I've been contemplating the potential benefits of leveraging the newer LLVM JIT API. This could allow us to phase out some of the older API dependencies. To keep discussions focused and avoid sidetracking this thread, I've opened a separate feature request at #37848 |
@kou I gave it a try to update Gandiva's code to use the new LLVM PassManager:
I've observed that the code I developed produces a different IR compared to the previously generated IR. Notably, the vector.body is absent in the IR, which I suspect is related to loop vectorization. I've attempted to troubleshoot by commenting out certain passes and adjusting the optimization level, but to no avail. I'm not well-versed in this area, so any insights or guidance would be greatly appreciated. Thank you. |
Thanks! It seems that the following passes are related: llvm::TargetIRAnalysis target_analysis =
execution_engine_->getTargetMachine()->getTargetIRAnalysis();
pass_manager->add(llvm::createTargetTransformInfoWrapperPass(target_analysis));
pass_manager->add(llvm::createFunctionInliningPass()); Because diff --git a/cpp/src/gandiva/engine.cc b/cpp/src/gandiva/engine.cc
index 7d75793a3..59fbad1d3 100644
--- a/cpp/src/gandiva/engine.cc
+++ b/cpp/src/gandiva/engine.cc
@@ -297,14 +297,14 @@ Status Engine::FinalizeModule() {
execution_engine_->getTargetMachine()->getTargetIRAnalysis();
pass_manager->add(llvm::createTargetTransformInfoWrapperPass(target_analysis));
pass_manager->add(llvm::createFunctionInliningPass());
- pass_manager->add(llvm::createInstructionCombiningPass());
- pass_manager->add(llvm::createPromoteMemoryToRegisterPass());
- pass_manager->add(llvm::createGVNPass());
- pass_manager->add(llvm::createNewGVNPass());
- pass_manager->add(llvm::createCFGSimplificationPass());
- pass_manager->add(llvm::createLoopVectorizePass());
- pass_manager->add(llvm::createSLPVectorizerPass());
- pass_manager->add(llvm::createGlobalOptimizerPass());
+ // pass_manager->add(llvm::createInstructionCombiningPass());
+ // pass_manager->add(llvm::createPromoteMemoryToRegisterPass());
+ // pass_manager->add(llvm::createGVNPass());
+ // pass_manager->add(llvm::createNewGVNPass());
+ // pass_manager->add(llvm::createCFGSimplificationPass());
+ // pass_manager->add(llvm::createLoopVectorizePass());
+ // pass_manager->add(llvm::createSLPVectorizerPass());
+ // pass_manager->add(llvm::createGlobalOptimizerPass());
// run the optimiser
llvm::PassManagerBuilder pass_builder; If I also comment out Are there corresponding passes for them in new LLVM PassManager? |
Thanks for the pointer, I read previously the target analysis pass is done by the new pass manager automatically but this could be wrong, I will do some more investigation to see if I can figure it out. |
Thanks! |
### Rationale for this change In #37834, to support LLVM 17, we need to migrate to use the new LLVM PassManager API. ### What changes are included in this PR? This PR tries to migrate the legacy PassManager to the new PassManager. ### Are these changes tested? It should be covered by existing unit tests. But more performance tests may be needed to verify this change. ### Are there any user-facing changes? No * Closes: #37834 Lead-authored-by: Yue Ni <niyue.com@gmail.com> Co-authored-by: Sutou Kouhei <kou@clear-code.com> Co-authored-by: Sutou Kouhei <kou@cozmixng.org> Signed-off-by: Sutou Kouhei <kou@clear-code.com>
…#37867) ### Rationale for this change In apache#37834, to support LLVM 17, we need to migrate to use the new LLVM PassManager API. ### What changes are included in this PR? This PR tries to migrate the legacy PassManager to the new PassManager. ### Are these changes tested? It should be covered by existing unit tests. But more performance tests may be needed to verify this change. ### Are there any user-facing changes? No * Closes: apache#37834 Lead-authored-by: Yue Ni <niyue.com@gmail.com> Co-authored-by: Sutou Kouhei <kou@clear-code.com> Co-authored-by: Sutou Kouhei <kou@cozmixng.org> Signed-off-by: Sutou Kouhei <kou@clear-code.com>
…#37867) ### Rationale for this change In apache#37834, to support LLVM 17, we need to migrate to use the new LLVM PassManager API. ### What changes are included in this PR? This PR tries to migrate the legacy PassManager to the new PassManager. ### Are these changes tested? It should be covered by existing unit tests. But more performance tests may be needed to verify this change. ### Are there any user-facing changes? No * Closes: apache#37834 Lead-authored-by: Yue Ni <niyue.com@gmail.com> Co-authored-by: Sutou Kouhei <kou@clear-code.com> Co-authored-by: Sutou Kouhei <kou@cozmixng.org> Signed-off-by: Sutou Kouhei <kou@clear-code.com>
…#37867) ### Rationale for this change In apache#37834, to support LLVM 17, we need to migrate to use the new LLVM PassManager API. ### What changes are included in this PR? This PR tries to migrate the legacy PassManager to the new PassManager. ### Are these changes tested? It should be covered by existing unit tests. But more performance tests may be needed to verify this change. ### Are there any user-facing changes? No * Closes: apache#37834 Lead-authored-by: Yue Ni <niyue.com@gmail.com> Co-authored-by: Sutou Kouhei <kou@clear-code.com> Co-authored-by: Sutou Kouhei <kou@cozmixng.org> Signed-off-by: Sutou Kouhei <kou@clear-code.com>
Describe the bug, including details regarding any error messages, version, and platform.
Arrow couldn't find llvm 17.0.1 because It's not listed.
Component(s)
C++
The text was updated successfully, but these errors were encountered: