[llvm] [llvm-ir2vec] Adding initEmbedding API to ir2vec python bindings (PR #177092)
Nishant Sachdeva via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 30 01:46:40 PST 2026
================
@@ -6,8 +6,80 @@
//
//===----------------------------------------------------------------------===//
+#include "lib/Utils.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IRReader/IRReader.h"
+#include "llvm/Support/SourceMgr.h"
+
#include <nanobind/nanobind.h>
+#include <nanobind/stl/string.h>
+#include <nanobind/stl/unique_ptr.h>
+
+#include <fstream>
+#include <memory>
+#include <string>
namespace nb = nanobind;
+using namespace llvm;
+using namespace llvm::ir2vec;
+
+namespace {
+
+std::unique_ptr<Module> getLLVMIR(const std::string &Filename,
+ LLVMContext &Context) {
+ SMDiagnostic Err;
+ auto M = parseIRFile(Filename, Err, Context);
+ if (!M)
+ throw nb::value_error(("Failed to parse IR file '" + Filename +
----------------
nishant-sachdeva wrote:
Alright, I'll push a patch to refine the bindings/cmakelists.txt to compile with an explicit `target_compile_options(ir2vec PRIVATE -fexceptions -frtti)`
https://github.com/llvm/llvm-project/pull/177092
More information about the llvm-commits
mailing list