[llvm] [llvm-ir2vec] Adding initEmbedding API to ir2vec python bindings (PR #177092)
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 28 22:01:58 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 +
----------------
mtrofin wrote:
I see. Maybe add a comment explaining and pointing out there's a precedent.
@nikic wdyt?
https://github.com/llvm/llvm-project/pull/177092
More information about the llvm-commits
mailing list