[llvm] [llvm-ir2vec] Setting up ir2vec python bindings testing for ml-opt bots (PR #194593)
Nishant Sachdeva via llvm-commits
llvm-commits at lists.llvm.org
Tue May 12 22:26:02 PDT 2026
https://github.com/nishant-sachdeva updated https://github.com/llvm/llvm-project/pull/194593
>From 04571fc2f7bc989cab14fd3f1a2b5e05858fad0b Mon Sep 17 00:00:00 2001
From: nishant_sachdeva <nishant.sachdeva at research.iiit.ac.in>
Date: Tue, 28 Apr 2026 16:18:33 +0530
Subject: [PATCH 1/7] Automating ir2vec python bindings testing in llvm CI
---
.ci/monolithic-linux.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/.ci/monolithic-linux.sh b/.ci/monolithic-linux.sh
index 29b0bdbd0e37b..7134973ca10b5 100755
--- a/.ci/monolithic-linux.sh
+++ b/.ci/monolithic-linux.sh
@@ -65,6 +65,7 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
-D CMAKE_DISABLE_PRECOMPILE_HEADERS=ON \
-D LIBCXX_CXX_ABI=libcxxabi \
-D MLIR_ENABLE_BINDINGS_PYTHON=ON \
+ -D LLVM_IR2VEC_ENABLE_PYTHON_BINDINGS=ON \
-D LLDB_ENABLE_PYTHON=ON \
-D LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=ON \
-D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
>From 5651116a119db25cc52790c1bc3c50acb38336d8 Mon Sep 17 00:00:00 2001
From: nishant_sachdeva <nishant.sachdeva at research.iiit.ac.in>
Date: Tue, 28 Apr 2026 16:24:26 +0530
Subject: [PATCH 2/7] Adding requirements.txt file with nanobind for ir2vec
python bindings
---
llvm/tools/llvm-ir2vec/Bindings/requirements.txt | 2 ++
1 file changed, 2 insertions(+)
create mode 100644 llvm/tools/llvm-ir2vec/Bindings/requirements.txt
diff --git a/llvm/tools/llvm-ir2vec/Bindings/requirements.txt b/llvm/tools/llvm-ir2vec/Bindings/requirements.txt
new file mode 100644
index 0000000000000..f9f555954f326
--- /dev/null
+++ b/llvm/tools/llvm-ir2vec/Bindings/requirements.txt
@@ -0,0 +1,2 @@
+# BUILD dependencies
+nanobind>=2.9, <3.0
\ No newline at end of file
>From 20b07e207dfccbfdb5edb3a9eb4862bb2946459f Mon Sep 17 00:00:00 2001
From: nishant_sachdeva <nishant.sachdeva at research.iiit.ac.in>
Date: Tue, 28 Apr 2026 16:26:11 +0530
Subject: [PATCH 3/7] Nit commit - formatting fixup
---
llvm/tools/llvm-ir2vec/Bindings/requirements.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/tools/llvm-ir2vec/Bindings/requirements.txt b/llvm/tools/llvm-ir2vec/Bindings/requirements.txt
index f9f555954f326..f5ea093068a2b 100644
--- a/llvm/tools/llvm-ir2vec/Bindings/requirements.txt
+++ b/llvm/tools/llvm-ir2vec/Bindings/requirements.txt
@@ -1,2 +1,2 @@
# BUILD dependencies
-nanobind>=2.9, <3.0
\ No newline at end of file
+nanobind>=2.9, <3.0
>From 40dd6cd0559df6d93a577b764655d5010c38be7a Mon Sep 17 00:00:00 2001
From: nishant_sachdeva <nishant.sachdeva at research.iiit.ac.in>
Date: Wed, 29 Apr 2026 13:03:10 +0530
Subject: [PATCH 4/7] Adding ir2vec target to lllvm test depends in order to
build the python bindings executable
---
llvm/test/CMakeLists.txt | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/llvm/test/CMakeLists.txt b/llvm/test/CMakeLists.txt
index a027cd754135c..6254db779801c 100644
--- a/llvm/test/CMakeLists.txt
+++ b/llvm/test/CMakeLists.txt
@@ -249,6 +249,10 @@ if (LLVM_INCLUDE_SPIRV_TOOLS_TESTS)
list(APPEND LLVM_TEST_DEPENDS spirv-link)
endif()
+if(LLVM_IR2VEC_TEST_PYTHON_BINDINGS)
+ list(APPEND LLVM_TEST_DEPENDS ir2vec)
+endif()
+
add_custom_target(llvm-test-depends DEPENDS ${LLVM_TEST_DEPENDS} UnitTests)
set_target_properties(llvm-test-depends PROPERTIES FOLDER "LLVM/Tests")
>From 200b9cfe6df830e5067e36f6217692245c71d3b6 Mon Sep 17 00:00:00 2001
From: nishant_sachdeva <nishant.sachdeva at research.iiit.ac.in>
Date: Wed, 29 Apr 2026 14:29:42 +0530
Subject: [PATCH 5/7] Work Commit - warnings in nanobind headers cause errors
on the upstream CI. adding flags to suppress them
---
.../tools/llvm-ir2vec/Bindings/CMakeLists.txt | 20 ++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/llvm/tools/llvm-ir2vec/Bindings/CMakeLists.txt b/llvm/tools/llvm-ir2vec/Bindings/CMakeLists.txt
index 582dfb3058385..d90722c7efcfd 100644
--- a/llvm/tools/llvm-ir2vec/Bindings/CMakeLists.txt
+++ b/llvm/tools/llvm-ir2vec/Bindings/CMakeLists.txt
@@ -35,9 +35,27 @@ nanobind_add_module(ir2vec MODULE PyIR2Vec.cpp)
# but Python bindings are compiled separately with these features enabled.
# This follows the pattern established by MLIR Python bindings
# (see mlir/cmake/modules/AddMLIRPython.cmake).
-target_compile_options(ir2vec PRIVATE -fexceptions -frtti)
+target_compile_options(ir2vec PRIVATE
+ -fexceptions
+ -frtti
+
+ -Wno-cast-qual
+ -Wno-zero-length-array
+ -Wno-covered-switch-default
+)
target_link_libraries(ir2vec PRIVATE LLVMEmbUtils)
target_include_directories(ir2vec PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..)
+# nanobind's own sources use patterns that are valid C++ but incompatible with
+# LLVM's strict -Werror warning policy (-Wcast-qual, -Wzero-length-array).
+# Suppress these warnings only on the nanobind library target, not on our code.
+if(TARGET nanobind-static)
+ target_compile_options(nanobind-static PRIVATE
+ -Wno-cast-qual
+ -Wno-zero-length-array
+ -Wno-covered-switch-default
+ )
+endif()
+
message(STATUS "Python bindings for llvm-ir2vec will be built with nanobind")
>From 3882d7a2c0d660da5674268801a7b47e10b394ae Mon Sep 17 00:00:00 2001
From: nishant_sachdeva <nishant.sachdeva at research.iiit.ac.in>
Date: Sat, 9 May 2026 16:38:54 +0530
Subject: [PATCH 6/7] Work Commit - removing LLVM_IR2VEC_ENABLE_PYTHON_BINDINGS
from ci linux build because PR is getting repurposed to provide groundwork
for ml-opt buildbot bindings tests
---
.ci/monolithic-linux.sh | 1 -
1 file changed, 1 deletion(-)
diff --git a/.ci/monolithic-linux.sh b/.ci/monolithic-linux.sh
index 7134973ca10b5..29b0bdbd0e37b 100755
--- a/.ci/monolithic-linux.sh
+++ b/.ci/monolithic-linux.sh
@@ -65,7 +65,6 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
-D CMAKE_DISABLE_PRECOMPILE_HEADERS=ON \
-D LIBCXX_CXX_ABI=libcxxabi \
-D MLIR_ENABLE_BINDINGS_PYTHON=ON \
- -D LLVM_IR2VEC_ENABLE_PYTHON_BINDINGS=ON \
-D LLDB_ENABLE_PYTHON=ON \
-D LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=ON \
-D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
>From 18203aa72d83cde7af5e62d55fa481a127a5678d Mon Sep 17 00:00:00 2001
From: nishant_sachdeva <nishant.sachdeva at research.iiit.ac.in>
Date: Wed, 13 May 2026 10:54:50 +0530
Subject: [PATCH 7/7] Work commit - dropping warning flag changes because
ml-opt bots do not run with LLVM_ENABLE_WERROR
---
.../tools/llvm-ir2vec/Bindings/CMakeLists.txt | 20 +------------------
1 file changed, 1 insertion(+), 19 deletions(-)
diff --git a/llvm/tools/llvm-ir2vec/Bindings/CMakeLists.txt b/llvm/tools/llvm-ir2vec/Bindings/CMakeLists.txt
index d90722c7efcfd..582dfb3058385 100644
--- a/llvm/tools/llvm-ir2vec/Bindings/CMakeLists.txt
+++ b/llvm/tools/llvm-ir2vec/Bindings/CMakeLists.txt
@@ -35,27 +35,9 @@ nanobind_add_module(ir2vec MODULE PyIR2Vec.cpp)
# but Python bindings are compiled separately with these features enabled.
# This follows the pattern established by MLIR Python bindings
# (see mlir/cmake/modules/AddMLIRPython.cmake).
-target_compile_options(ir2vec PRIVATE
- -fexceptions
- -frtti
-
- -Wno-cast-qual
- -Wno-zero-length-array
- -Wno-covered-switch-default
-)
+target_compile_options(ir2vec PRIVATE -fexceptions -frtti)
target_link_libraries(ir2vec PRIVATE LLVMEmbUtils)
target_include_directories(ir2vec PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..)
-# nanobind's own sources use patterns that are valid C++ but incompatible with
-# LLVM's strict -Werror warning policy (-Wcast-qual, -Wzero-length-array).
-# Suppress these warnings only on the nanobind library target, not on our code.
-if(TARGET nanobind-static)
- target_compile_options(nanobind-static PRIVATE
- -Wno-cast-qual
- -Wno-zero-length-array
- -Wno-covered-switch-default
- )
-endif()
-
message(STATUS "Python bindings for llvm-ir2vec will be built with nanobind")
More information about the llvm-commits
mailing list