[llvm-branch-commits] [llvm] [IR2Vec] Add llvm-ir2vec tool for generating triplet embeddings (PR #147842)

Aiden Grossman via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Jul 14 09:16:48 PDT 2025


================
@@ -0,0 +1,150 @@
+//===- llvm-ir2vec.cpp - IR2Vec Embedding Generation Tool -----------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file implements the IR2Vec embedding generation tool.
+///
+/// Currently supports triplet generation for vocabulary training.
+/// Future updates will support embedding generation using trained vocabulary.
+///
+/// Usage: llvm-ir2vec input.bc -o triplets.txt
+///
+/// TODO: Add embedding generation mode with vocabulary support
+///
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Analysis/IR2Vec.h"
+#include "llvm/IR/BasicBlock.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/Instructions.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/Type.h"
+#include "llvm/IRReader/IRReader.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/Errc.h"
+#include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/SourceMgr.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace llvm;
+using namespace ir2vec;
----------------
boomanaiden154 wrote:

Copying from the subsequent PR that I reviewed first:

Instead of using statements, it might be better to wrap everything outside of main in an anonymous namespace inside the llvm::ir2vec namespace. I'm not sure what the coding standards are, but that's the pattern I see in other tools like llvm-exegesis.

https://github.com/llvm/llvm-project/pull/147842


More information about the llvm-branch-commits mailing list